fix: socket should not notify hidden folder or file

fix: socket should not notify hidden folder
This commit is contained in:
Methapon2001 2023-12-15 16:18:40 +07:00
parent 7a0727927b
commit 7eada9e0dd
No known key found for this signature in database
GPG key ID: 849924FEF46BD132
2 changed files with 41 additions and 35 deletions

View file

@ -1,7 +1,7 @@
import { StorageFile } from "../interfaces/storage-fs";
import esClient from "../elasticsearch";
import minioClient from "../minio";
import { getInstance } from "../lib/websocket";
import * as io from "../lib/websocket";
const DEFAULT_INDEX = process.env.ELASTICSEARCH_INDEX;
@ -44,7 +44,7 @@ export async function handler(key: string, event: string): Promise<boolean> {
const rec = await popInfo(pathname);
console.info(`[AMQ] Key: ${key} - ${rec ?? "Not Found."}`);
console.info(`[AMQ] Key: ${key} - ${JSON.stringify(rec, null, 2) ?? "Not Found."}`);
const result = rec
? await handleFoundRecord(rec, cachedBuffer[key], cachedMetadata[key])
@ -96,8 +96,7 @@ async function ensureDelete(pathname: string) {
})
.catch((e) => console.error(e));
const io = getInstance();
io?.emit("FileDelete", { pathname });
io.getInstance()?.emit("FileDelete", { pathname });
return true;
}
@ -144,8 +143,9 @@ async function handleNotFoundRecord(
if (!result) return false;
const io = getInstance();
io?.emit("FileUpload", metadata);
if (!metadata.hidden) {
io.getInstance()?.emit("FileUpload", metadata);
}
return true;
}
@ -170,8 +170,9 @@ async function handleFoundRecord(
if (!result) return false;
const io = getInstance();
io?.emit("FileUpload", metadata);
if (!metadata.hidden) {
io.getInstance()?.emit("FileUpload", metadata);
}
return true;
}