hardcode filter for now
This commit is contained in:
parent
2c8a65f959
commit
7a42938523
|
@ -168,13 +168,16 @@ class FavroFuse(fuse.Fuse):
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
*,
|
||||||
favro_client: FavroClient,
|
favro_client: FavroClient,
|
||||||
formatter: CardFileFormatter,
|
formatter: CardFileFormatter,
|
||||||
|
collection_filter: frozenset[str],
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
self.favro_client = favro_client
|
self.favro_client = favro_client
|
||||||
self.formatter = formatter
|
self.formatter = formatter
|
||||||
self.wiped_cards = set()
|
self.wiped_cards = set()
|
||||||
|
self.collection_filter = collection_filter
|
||||||
self.path_components = [
|
self.path_components = [
|
||||||
RootFileSystemItem,
|
RootFileSystemItem,
|
||||||
CollectionFileSystemItem,
|
CollectionFileSystemItem,
|
||||||
|
@ -209,6 +212,9 @@ class FavroFuse(fuse.Fuse):
|
||||||
return -errno.ENOENT
|
return -errno.ENOENT
|
||||||
return st
|
return st
|
||||||
|
|
||||||
|
def _is_allowed_collection(self, item: CollectionFileSystemItem) -> bool:
|
||||||
|
return item.collection_name in self.collection_filter
|
||||||
|
|
||||||
def readdir(self, path: str, offset: int) -> Iterator[fuse.Direntry]:
|
def readdir(self, path: str, offset: int) -> Iterator[fuse.Direntry]:
|
||||||
logger.info('Reading directory: %s', path)
|
logger.info('Reading directory: %s', path)
|
||||||
file_system_item = path_to_file_system_item(path, self.path_components)
|
file_system_item = path_to_file_system_item(path, self.path_components)
|
||||||
|
@ -218,11 +224,15 @@ class FavroFuse(fuse.Fuse):
|
||||||
|
|
||||||
if isinstance(file_system_item, RootFileSystemItem):
|
if isinstance(file_system_item, RootFileSystemItem):
|
||||||
for collection in self.favro_client.get_collections():
|
for collection in self.favro_client.get_collections():
|
||||||
collection_name = collection.name.replace('/', '')
|
item = CollectionFileSystemItem(collection.name.replace('/', ''))
|
||||||
yield fuse.Direntry(str(CollectionFileSystemItem(collection_name)))
|
if self._is_allowed_collection(item):
|
||||||
del collection
|
yield fuse.Direntry(str(item))
|
||||||
|
del collection, item
|
||||||
|
|
||||||
elif isinstance(file_system_item, CollectionFileSystemItem):
|
elif isinstance(file_system_item, CollectionFileSystemItem):
|
||||||
|
if not self._is_allowed_collection(file_system_item):
|
||||||
|
return # Yield nothing
|
||||||
|
|
||||||
# TODO: move into own function
|
# TODO: move into own function
|
||||||
for collection in self.favro_client.get_collections():
|
for collection in self.favro_client.get_collections():
|
||||||
if collection.name.replace('/', '') == file_system_item.collection_name:
|
if collection.name.replace('/', '') == file_system_item.collection_name:
|
||||||
|
@ -339,10 +349,12 @@ Userspace hello example
|
||||||
|
|
||||||
def start_favro_fuse(favro_client: FavroClient):
|
def start_favro_fuse(favro_client: FavroClient):
|
||||||
logger.info('Starting favro FUSE')
|
logger.info('Starting favro FUSE')
|
||||||
|
collection_filter = frozenset(['Platform'])
|
||||||
# TODO:
|
# TODO:
|
||||||
server = FavroFuse(
|
server = FavroFuse(
|
||||||
favro_client=favro_client,
|
favro_client=favro_client,
|
||||||
formatter=CardFileFormatter(),
|
formatter=CardFileFormatter(),
|
||||||
|
collection_filter=collection_filter,
|
||||||
version='%prog ' + fuse.__version__,
|
version='%prog ' + fuse.__version__,
|
||||||
usage=HELP,
|
usage=HELP,
|
||||||
dash_s_do='setsingle',
|
dash_s_do='setsingle',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user