@@ -53,6 +53,7 @@ def __init__(self, config: traitlets.config.Config) -> None:
5353 self ._max_files_listed = 1025
5454 self ._drives = None
5555 self ._external_drives = {}
56+ self ._excluded_drives = set ()
5657
5758 # instate fsspec file system
5859 self ._file_system = fsspec .filesystem (self ._config .provider , asynchronous = True )
@@ -171,6 +172,22 @@ def set_listing_limit(self, new_limit):
171172
172173 return
173174
175+ def exclude_drive (self , exclude_drive_name ):
176+ """Exclude drive from listing.
177+
178+ Args:
179+ exclude_bucket_name: drive to exclude
180+ """
181+ try :
182+ self ._excluded_drives .add (exclude_drive_name );
183+ except Exception as e :
184+ raise tornado .web .HTTPError (
185+ status_code = httpx .codes .BAD_REQUEST ,
186+ reason = f"The following error occured when excluding the drive: { e } "
187+ )
188+
189+ return
190+
174191 async def list_drives (self ):
175192 """Get list of available drives.
176193
@@ -196,15 +213,16 @@ async def list_drives(self):
196213 )
197214
198215 for result in results :
199- data .append (
200- {
201- "name" : result .name ,
202- "region" : self ._config .region_name ,
203- "creationDate" : result .extra ["creation_date" ],
204- "mounted" : False if result .name not in self ._content_managers else True ,
205- "provider" : self ._config .provider
206- }
207- )
216+ if result .name not in self ._excluded_drives :
217+ data .append (
218+ {
219+ "name" : result .name ,
220+ "region" : self ._config .region_name ,
221+ "creationDate" : result .extra ["creation_date" ],
222+ "mounted" : False if result .name not in self ._content_managers else True ,
223+ "provider" : self ._config .provider
224+ }
225+ )
208226
209227 if len (self ._external_drives ) != 0 :
210228 for drive in self ._external_drives .values ():
0 commit comments