# new EnhancedFileSystemCache()
Example
import { EnhancedFileSystemCache } from 'muziertcclient';
// Reinitialize cache with retry logic
const cache = await EnhancedFileSystemCache.clearAndReinit(userId, roomName, client);
const tree = await EnhancedFileSystemCache.getFileTreeWithInit(cache);
Methods
# async static clearAndReinit(userId, roomName, client, isRoomOwner) → {Promise.<(Object|null)>}
Clear and reinitialize cache for a specific user/room
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
userId |
string
|
User ID |
|
roomName |
string
|
Room name |
|
client |
Object
|
HiyveClient instance |
|
isRoomOwner |
boolean
|
false | Whether the user is the room owner (default: false) |
New cache instance or null if failed
Promise.<(Object|null)>
Example
// Clear old cache and get fresh data
const cache = await EnhancedFileSystemCache.clearAndReinit(
'user123', 'meeting-room', muzieClient, true
);
# static extractFolderFromTree(tree, targetPath) → {Object|null}
Extract folder contents from file tree by path
Parameters:
| Name | Type | Description |
|---|---|---|
tree |
Object
|
File tree object |
targetPath |
string
|
Path to extract |
Folder node or null if not found
Object
|
null
Example
const tree = await cache.getFileTree();
const folder = EnhancedFileSystemCache.extractFolderFromTree(tree, '/docs/reports');
# static filterTreeByRoom(treeNode, roomName, userId) → {Object|null}
Recursively filters a file tree to only include folders that contain files from the specified room
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
treeNode |
Object
|
Tree node to filter |
|
roomName |
string
|
Room name to filter by |
|
userId |
string
|
null | Current user ID for checking sharing permissions |
Filtered tree node or null if no relevant content
Object
|
null
Example
const tree = await cache.getFileTree();
const filtered = EnhancedFileSystemCache.filterTreeByRoom(tree, 'my-room', 'user123');
# async static folderContainsRoomFilesWithInit(cache, folderPath, roomName) → {Promise.<boolean>}
Check if a folder (at any depth) contains files from the specified room
Parameters:
| Name | Type | Description |
|---|---|---|
cache |
Object
|
Cache instance |
folderPath |
string
|
Path to the folder to check |
roomName |
string
|
Room name to look for |
True if folder contains files from the room
Promise.<boolean>
Example
const hasFiles = await EnhancedFileSystemCache.folderContainsRoomFilesWithInit(
cache, '/shared/docs', 'team-meeting'
);
# async static getFileTreeByRoomWithInit(cache, roomName) → {Promise.<Object>}
Get file tree by room with initialization check (for room owners only)
Parameters:
| Name | Type | Description |
|---|---|---|
cache |
Object
|
Cache instance |
roomName |
string
|
Room name to filter by |
File tree for the specified room
Promise.<Object>
Example
// As room owner, get tree for a specific room
const tree = await EnhancedFileSystemCache.getFileTreeByRoomWithInit(cache, 'team-meeting');
# async static getFileTreeWithInit(cache, waitForSync) → {Promise.<Object>}
Get file tree with initialization check
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
cache |
Object
|
Cache instance |
|
waitForSync |
boolean
|
false | Whether to wait for sync |
File tree
Promise.<Object>
Example
const tree = await EnhancedFileSystemCache.getFileTreeWithInit(cache, true);
console.log('Root folders:', Object.keys(tree.children));
# async static getFilesByRoomWithInit(cache, roomName) → {Promise.<Array>}
Get files by room with initialization check (for room owners only)
Parameters:
| Name | Type | Description |
|---|---|---|
cache |
Object
|
Cache instance |
roomName |
string
|
Room name to filter by |
Array of files for the specified room
Promise.<Array>
Example
// As room owner, get files for a specific room
const files = await EnhancedFileSystemCache.getFilesByRoomWithInit(cache, 'team-meeting');
# async static getFilesByTypeWithInit(cache, resourceType) → {Promise.<Array>}
Get files by type with initialization check
Parameters:
| Name | Type | Description |
|---|---|---|
cache |
Object
|
Cache instance |
resourceType |
string
|
Resource type to filter by |
Array of files
Promise.<Array>
Example
const recordings = await EnhancedFileSystemCache.getFilesByTypeWithInit(cache, 'recording');
# async static getFilteredFolderTreeWithInit(cache, roomName) → {Promise.<Object>}
Get filtered folder tree - only shows folders containing files from specified room
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
cache |
Object
|
Cache instance |
|
roomName |
string
|
null | Room name to filter by (null for all rooms) |
Filtered file tree showing only relevant folders
Promise.<Object>
Example
// Show only folders with files from current room
const tree = await EnhancedFileSystemCache.getFilteredFolderTreeWithInit(cache, 'my-room');
# async static initializeWithRetry(cache, maxRetries) → {Promise.<void>}
Initialize cache with retry logic and exponential backoff
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
cache |
Object
|
Cache instance to initialize |
|
maxRetries |
number
|
3 | Maximum retry attempts (default: 3) |
Promise.<void>
Example
const cache = getFileSystemCache({ userId, roomName, client });
await EnhancedFileSystemCache.initializeWithRetry(cache, 5);
# static isFileAccessibleInRoom(file, roomName, userId) → {boolean}
Check if a file is accessible to a user in a specific room
Parameters:
| Name | Type | Description |
|---|---|---|
file |
Object
|
File object |
roomName |
string
|
Room name to check |
userId |
string
|
User ID to check access for |
True if file is accessible
boolean
Example
const canAccess = EnhancedFileSystemCache.isFileAccessibleInRoom(file, 'my-room', 'user123');
if (canAccess) {
displayFile(file);
}
# async static loadFolderContents(cache, path) → {Promise.<Object>}
Load folder contents by extracting from file tree
Parameters:
| Name | Type | Description |
|---|---|---|
cache |
Object
|
Cache instance |
path |
string
|
Folder path to load |
Folder node with children
Promise.<Object>
Example
const folder = await EnhancedFileSystemCache.loadFolderContents(cache, '/documents');
console.log('Files in folder:', Object.keys(folder.children));
# async static performOperationWithInit(cache, operation, operationFn) → {Promise.<any>}
Perform file operation with initialization check
Parameters:
| Name | Type | Description |
|---|---|---|
cache |
Object
|
Cache instance |
operation |
string
|
Operation name |
operationFn |
function
|
Function to execute |
Operation result
Promise.<any>
Example
const result = await EnhancedFileSystemCache.performOperationWithInit(
cache, 'moveFile',
() => cache.moveFile('file123', '/new/location')
);