Compare commits
No commits in common. "a1f4a8207e5b1e77112d407d959cd53d37b67032" and "2c8a65f959e870a5377b45d6c903ad528cf9c0f5" have entirely different histories.
a1f4a8207e
...
2c8a65f959
|
@ -29,7 +29,7 @@ def main():
|
|||
)
|
||||
|
||||
client.check_logged_in()
|
||||
start_favro_fuse(client, secrets.favro_collection_filter())
|
||||
start_favro_fuse(client)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -215,7 +215,7 @@ class FavroClient:
|
|||
def _invalidate_cache(self, card_id: CardId) -> None:
|
||||
card = self.card_cache.remove(card_id)
|
||||
if card:
|
||||
self.session.cache.delete(
|
||||
self.session.card_cache.delete(
|
||||
requests=[self._get_cards_prepared_request(seq_id=card.seq_id)],
|
||||
)
|
||||
|
||||
|
|
|
@ -168,16 +168,13 @@ class FavroFuse(fuse.Fuse):
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
favro_client: FavroClient,
|
||||
formatter: CardFileFormatter,
|
||||
collection_filter: frozenset[str],
|
||||
**kwargs,
|
||||
):
|
||||
self.favro_client = favro_client
|
||||
self.formatter = formatter
|
||||
self.wiped_cards = set()
|
||||
self.collection_filter = collection_filter
|
||||
self.path_components = [
|
||||
RootFileSystemItem,
|
||||
CollectionFileSystemItem,
|
||||
|
@ -212,11 +209,6 @@ class FavroFuse(fuse.Fuse):
|
|||
return -errno.ENOENT
|
||||
return st
|
||||
|
||||
def _is_allowed_collection(self, item: CollectionFileSystemItem) -> bool:
|
||||
if self.collection_filter is None:
|
||||
return True
|
||||
return item.collection_name in self.collection_filter
|
||||
|
||||
def readdir(self, path: str, offset: int) -> Iterator[fuse.Direntry]:
|
||||
logger.info('Reading directory: %s', path)
|
||||
file_system_item = path_to_file_system_item(path, self.path_components)
|
||||
|
@ -226,15 +218,11 @@ class FavroFuse(fuse.Fuse):
|
|||
|
||||
if isinstance(file_system_item, RootFileSystemItem):
|
||||
for collection in self.favro_client.get_collections():
|
||||
item = CollectionFileSystemItem(collection.name.replace('/', ''))
|
||||
if self._is_allowed_collection(item):
|
||||
yield fuse.Direntry(str(item))
|
||||
del collection, item
|
||||
collection_name = collection.name.replace('/', '')
|
||||
yield fuse.Direntry(str(CollectionFileSystemItem(collection_name)))
|
||||
del collection
|
||||
|
||||
elif isinstance(file_system_item, CollectionFileSystemItem):
|
||||
if not self._is_allowed_collection(file_system_item):
|
||||
return # Yield nothing
|
||||
|
||||
# TODO: move into own function
|
||||
for collection in self.favro_client.get_collections():
|
||||
if collection.name.replace('/', '') == file_system_item.collection_name:
|
||||
|
@ -349,12 +337,12 @@ Userspace hello example
|
|||
)
|
||||
|
||||
|
||||
def start_favro_fuse(favro_client: FavroClient, collection_filter: frozenset[str]):
|
||||
logger.info('Starting favro FUSE with collection filter: %s', collection_filter)
|
||||
def start_favro_fuse(favro_client: FavroClient):
|
||||
logger.info('Starting favro FUSE')
|
||||
# TODO:
|
||||
server = FavroFuse(
|
||||
favro_client=favro_client,
|
||||
formatter=CardFileFormatter(),
|
||||
collection_filter=collection_filter,
|
||||
version='%prog ' + fuse.__version__,
|
||||
usage=HELP,
|
||||
dash_s_do='setsingle',
|
||||
|
|
|
@ -17,13 +17,3 @@ def favro_username():
|
|||
|
||||
def favro_password():
|
||||
return secrets.load_or_fail('FAVRO_PASSWORD')
|
||||
|
||||
|
||||
def favro_collection_filter() -> frozenset[str]:
|
||||
loaded = secrets.load('FAVRO_COLLECTION_FILTER')
|
||||
if loaded is None:
|
||||
return None
|
||||
values = loaded.strip().split('\n')
|
||||
values = [v.strip() for v in values]
|
||||
values = [v for v in values if v]
|
||||
return frozenset(values)
|
||||
|
|
Loading…
Reference in New Issue
Block a user