bug fix on file dispaly, document update
This commit is contained in:
@@ -74,9 +74,12 @@ export interface LeaderLockInfo {
|
||||
/** Redis connection URL (e.g., redis://10.0.1.50:6379) */
|
||||
redisUrl: string;
|
||||
|
||||
/** WebDAV URL for file access */
|
||||
/** WebDAV URL for file access (external, via nginx/HTTPS) */
|
||||
webdavUrl: string;
|
||||
|
||||
/** WebDAV URL for internal container-to-container access (direct to port 9000) */
|
||||
webdavUrlInternal: string;
|
||||
|
||||
/** Timestamp when leadership was acquired */
|
||||
timestamp: number;
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ export interface URLsResponse {
|
||||
apiUrl: string;
|
||||
redisUrl: string;
|
||||
webdavUrl: string;
|
||||
webdavUrlInternal: string;
|
||||
isLeader: boolean;
|
||||
}
|
||||
|
||||
@@ -120,6 +121,7 @@ export class LeaderClient {
|
||||
apiUrl: urls.apiUrl,
|
||||
redisUrl: urls.redisUrl,
|
||||
webdavUrl: urls.webdavUrl,
|
||||
webdavUrlInternal: urls.webdavUrlInternal,
|
||||
timestamp: Date.now(),
|
||||
pid: 0 // Unknown for remote leader
|
||||
};
|
||||
@@ -139,13 +141,22 @@ export class LeaderClient {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get WebDAV URL from leader info
|
||||
* Get WebDAV URL from leader info (external, via nginx/HTTPS)
|
||||
*/
|
||||
async getWebdavUrl(): Promise<string | null> {
|
||||
const info = await this.getLeaderInfo();
|
||||
return info?.webdavUrl ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get internal WebDAV URL from leader info (direct to port 9000)
|
||||
* Use this for container-to-container communication
|
||||
*/
|
||||
async getWebdavUrlInternal(): Promise<string | null> {
|
||||
const info = await this.getLeaderInfo();
|
||||
return info?.webdavUrlInternal ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get meta-core API URL from leader info
|
||||
*/
|
||||
|
||||
@@ -463,6 +463,76 @@ export class RedisClient implements Partial<IKVClient> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan flat keys to build file metadata for all indexed files
|
||||
* This is used as a fallback when the meta:events stream is empty or unavailable.
|
||||
*
|
||||
* Algorithm:
|
||||
* 1. Get all hash IDs from the index
|
||||
* 2. For each hash ID, fetch VFS-relevant properties using MGET
|
||||
* 3. Return a Map of hashId to flat properties
|
||||
*
|
||||
* This replaces the broken getAllFiles() which used HGETALL on flat keys.
|
||||
*
|
||||
* @param vfsRelevantProperties - Set of property names that are VFS-relevant
|
||||
* @returns Map of hashId to properties (only files with filePath)
|
||||
*/
|
||||
async scanFlatKeysForFiles(vfsRelevantProperties: Set<string>): Promise<Map<string, Record<string, string>>> {
|
||||
const result = new Map<string, Record<string, string>>();
|
||||
|
||||
if (!this.client || !this.isConnected) {
|
||||
logger.warn('Redis not connected, returning empty result');
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
// Get all hash IDs from the index
|
||||
const hashIds = await this.getAllHashIds();
|
||||
logger.info(`Scanning flat keys for ${hashIds.length} files...`);
|
||||
|
||||
if (hashIds.length === 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Batch process hashIds to avoid overwhelming Redis
|
||||
const batchSize = 100;
|
||||
const propertiesArray = Array.from(vfsRelevantProperties);
|
||||
|
||||
for (let i = 0; i < hashIds.length; i += batchSize) {
|
||||
const batch = hashIds.slice(i, i + batchSize);
|
||||
|
||||
// Process each hashId in the batch
|
||||
const batchPromises = batch.map(async (hashId) => {
|
||||
const props = await this.getProperties(hashId, propertiesArray);
|
||||
|
||||
// Only include files that have a filePath
|
||||
if (props.has('filePath')) {
|
||||
const propsObj: Record<string, string> = {};
|
||||
for (const [key, value] of props) {
|
||||
propsObj[key] = value;
|
||||
}
|
||||
return { hashId, props: propsObj };
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
const batchResults = await Promise.all(batchPromises);
|
||||
|
||||
for (const item of batchResults) {
|
||||
if (item) {
|
||||
result.set(item.hashId, item.props);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(`Flat key scan complete: ${result.size} files with filePath`);
|
||||
return result;
|
||||
} catch (error: any) {
|
||||
logger.error('Failed to scan flat keys:', error.message);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan Redis keys matching pattern
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user