Retrieve the unencrypted folder key from nested_share_folders or subfolder_cache.
(params, folder_uid: str, raise_on_missing: bool = True)
| 20 | # ═══════════════════════════════════════════════════════════════════════════ |
| 21 | |
| 22 | def get_folder_key(params, folder_uid: str, raise_on_missing: bool = True) -> Optional[bytes]: |
| 23 | """Retrieve the unencrypted folder key from nested_share_folders or subfolder_cache.""" |
| 24 | for cache in (getattr(params, 'nested_share_folders', {}), |
| 25 | getattr(params, 'subfolder_cache', {})): |
| 26 | obj = cache.get(folder_uid) |
| 27 | if obj and 'folder_key_unencrypted' in obj: |
| 28 | return obj['folder_key_unencrypted'] |
| 29 | if raise_on_missing: |
| 30 | raise ValueError( |
| 31 | f"Folder key not found for folder {folder_uid}. " |
| 32 | f"Try running 'sync-down' first.") |
| 33 | return None |
| 34 | |
| 35 | |
| 36 | def get_record_key(params, record_uid: str, raise_on_missing: bool = True) -> Optional[bytes]: |
no test coverage detected