File tree Expand file tree Collapse file tree 4 files changed +44
-0
lines changed Expand file tree Collapse file tree 4 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -653,6 +653,18 @@ impl ObjectStorage for BlobStore {
653653 . collect :: < Vec < _ > > ( ) )
654654 }
655655
656+ async fn list_dirs_relative ( & self , relative_path : & RelativePath ) -> Result < Vec < String > , ObjectStorageError > {
657+ let prefix = object_store:: path:: Path :: from ( relative_path. as_str ( ) ) ;
658+ let resp = self . client . list_with_delimiter ( Some ( & prefix) ) . await ?;
659+
660+ Ok ( resp
661+ . common_prefixes
662+ . iter ( )
663+ . flat_map ( |path| path. parts ( ) )
664+ . map ( |name| name. as_ref ( ) . to_string ( ) )
665+ . collect :: < Vec < _ > > ( ) )
666+ }
667+
656668 async fn get_all_dashboards (
657669 & self ,
658670 ) -> Result < HashMap < RelativePathBuf , Vec < Bytes > > , ObjectStorageError > {
Original file line number Diff line number Diff line change @@ -353,6 +353,25 @@ impl ObjectStorage for LocalFS {
353353 Ok ( dirs)
354354 }
355355
356+
357+ async fn list_dirs_relative ( & self , relative_path : & RelativePath ) -> Result < Vec < String > , ObjectStorageError > {
358+ let root = self . root . join ( relative_path. as_str ( ) ) ;
359+ let dirs = ReadDirStream :: new ( fs:: read_dir ( root) . await ?)
360+ . try_collect :: < Vec < DirEntry > > ( )
361+ . await ?
362+ . into_iter ( )
363+ . map ( dir_name) ;
364+
365+ let dirs = FuturesUnordered :: from_iter ( dirs)
366+ . try_collect :: < Vec < _ > > ( )
367+ . await ?
368+ . into_iter ( )
369+ . flatten ( )
370+ . collect :: < Vec < _ > > ( ) ;
371+
372+ Ok ( dirs)
373+ }
374+
356375 async fn get_all_dashboards (
357376 & self ,
358377 ) -> Result < HashMap < RelativePathBuf , Vec < Bytes > > , ObjectStorageError > {
Original file line number Diff line number Diff line change @@ -94,6 +94,7 @@ pub trait ObjectStorage: Debug + Send + Sync + 'static {
9494 async fn list_streams ( & self ) -> Result < HashSet < LogStream > , ObjectStorageError > ;
9595 async fn list_old_streams ( & self ) -> Result < HashSet < LogStream > , ObjectStorageError > ;
9696 async fn list_dirs ( & self ) -> Result < Vec < String > , ObjectStorageError > ;
97+ async fn list_dirs_relative ( & self , relative_path : & RelativePath ) -> Result < Vec < String > , ObjectStorageError > ;
9798 async fn get_all_saved_filters (
9899 & self ,
99100 ) -> Result < HashMap < RelativePathBuf , Vec < Bytes > > , ObjectStorageError > ;
Original file line number Diff line number Diff line change @@ -786,6 +786,18 @@ impl ObjectStorage for S3 {
786786 . collect :: < Vec < _ > > ( ) )
787787 }
788788
789+ async fn list_dirs_relative ( & self , relative_path : & RelativePath ) -> Result < Vec < String > , ObjectStorageError > {
790+ let prefix = object_store:: path:: Path :: from ( relative_path. as_str ( ) ) ;
791+ let resp = self . client . list_with_delimiter ( Some ( & prefix) ) . await ?;
792+
793+ Ok ( resp
794+ . common_prefixes
795+ . iter ( )
796+ . flat_map ( |path| path. parts ( ) )
797+ . map ( |name| name. as_ref ( ) . to_string ( ) )
798+ . collect :: < Vec < _ > > ( ) )
799+ }
800+
789801 async fn get_all_dashboards (
790802 & self ,
791803 ) -> Result < HashMap < RelativePathBuf , Vec < Bytes > > , ObjectStorageError > {
You can’t perform that action at this time.
0 commit comments