fix: socket should not notify hidden folder or file
fix: socket should not notify hidden folder
This commit is contained in:
parent
7a0727927b
commit
7eada9e0dd
2 changed files with 41 additions and 35 deletions
|
|
@ -309,13 +309,14 @@ export class StorageController extends Controller {
|
||||||
|
|
||||||
if (!created) throw new Error(MINIO_ERROR_MESSAGE);
|
if (!created) throw new Error(MINIO_ERROR_MESSAGE);
|
||||||
|
|
||||||
io.getInstance()?.emit("FolderCreate", {
|
!name.startsWith(".") &&
|
||||||
pathname: stripLeadingSlash(
|
io.getInstance()?.emit("FolderCreate", {
|
||||||
`${path.join("/")}/${name.replace(/[/\\?%*:|"<>#]/g, "-").trim()}/`,
|
pathname: stripLeadingSlash(
|
||||||
),
|
`${path.join("/")}/${name.replace(/[/\\?%*:|"<>#]/g, "-").trim()}/`,
|
||||||
name: name.replace(/[/\\?%*:|"<>#]/g, "-").trim(),
|
),
|
||||||
...meta,
|
name: name.replace(/[/\\?%*:|"<>#]/g, "-").trim(),
|
||||||
});
|
...meta,
|
||||||
|
});
|
||||||
|
|
||||||
return this.setStatus(HttpStatusCode.NO_CONTENT);
|
return this.setStatus(HttpStatusCode.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
@ -550,7 +551,7 @@ export class StorageController extends Controller {
|
||||||
refresh: "wait_for", // Must have or else it doesn't wait for updated index resulted in data not found on fetch
|
refresh: "wait_for", // Must have or else it doesn't wait for updated index resulted in data not found on fetch
|
||||||
});
|
});
|
||||||
|
|
||||||
io.getInstance()?.emit("FileUploadRequest", metadata);
|
!metadata.hidden && io.getInstance()?.emit("FileUploadRequest", metadata);
|
||||||
|
|
||||||
const presignedUrl = await minioClient.presignedPutObject(DEFAULT_BUCKET, metadata.pathname);
|
const presignedUrl = await minioClient.presignedPutObject(DEFAULT_BUCKET, metadata.pathname);
|
||||||
|
|
||||||
|
|
@ -664,17 +665,19 @@ export class StorageController extends Controller {
|
||||||
)
|
)
|
||||||
.catch((e) => console.error(`ElasticSearch Error: ${e}`));
|
.catch((e) => console.error(`ElasticSearch Error: ${e}`));
|
||||||
|
|
||||||
io.getInstance()?.emit("FileMove", {
|
if (!source.hidden && !metadata.hidden) {
|
||||||
from: source,
|
io.getInstance()?.emit("FileMove", {
|
||||||
to: {
|
from: source,
|
||||||
...source,
|
to: {
|
||||||
...metadata,
|
...source,
|
||||||
path: stripLeadingSlash(`${to.path.join("/")}/`),
|
...metadata,
|
||||||
pathname: dst,
|
path: stripLeadingSlash(`${to.path.join("/")}/`),
|
||||||
fileName: to.file,
|
pathname: dst,
|
||||||
...dateMeta,
|
fileName: to.file,
|
||||||
},
|
...dateMeta,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (upload) {
|
if (upload) {
|
||||||
const presignedUrl = await minioClient.presignedPutObject(DEFAULT_BUCKET, dst);
|
const presignedUrl = await minioClient.presignedPutObject(DEFAULT_BUCKET, dst);
|
||||||
|
|
@ -697,14 +700,16 @@ export class StorageController extends Controller {
|
||||||
})
|
})
|
||||||
.catch((e) => console.error(`ElasticSearch Error: ${e}`));
|
.catch((e) => console.error(`ElasticSearch Error: ${e}`));
|
||||||
|
|
||||||
io.getInstance()?.emit("FileMove", {
|
if (!source.hidden && !metadata.hidden) {
|
||||||
from: source,
|
io.getInstance()?.emit("FileMove", {
|
||||||
to: {
|
from: source,
|
||||||
...source,
|
to: {
|
||||||
...metadata,
|
...source,
|
||||||
...dateMeta,
|
...metadata,
|
||||||
},
|
...dateMeta,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (upload) {
|
if (upload) {
|
||||||
const src = stripLeadingSlash(`${from.path.join("/")}/${from.file}`);
|
const src = stripLeadingSlash(`${from.path.join("/")}/${from.file}`);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { StorageFile } from "../interfaces/storage-fs";
|
import { StorageFile } from "../interfaces/storage-fs";
|
||||||
import esClient from "../elasticsearch";
|
import esClient from "../elasticsearch";
|
||||||
import minioClient from "../minio";
|
import minioClient from "../minio";
|
||||||
import { getInstance } from "../lib/websocket";
|
import * as io from "../lib/websocket";
|
||||||
|
|
||||||
const DEFAULT_INDEX = process.env.ELASTICSEARCH_INDEX;
|
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);
|
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
|
const result = rec
|
||||||
? await handleFoundRecord(rec, cachedBuffer[key], cachedMetadata[key])
|
? await handleFoundRecord(rec, cachedBuffer[key], cachedMetadata[key])
|
||||||
|
|
@ -96,8 +96,7 @@ async function ensureDelete(pathname: string) {
|
||||||
})
|
})
|
||||||
.catch((e) => console.error(e));
|
.catch((e) => console.error(e));
|
||||||
|
|
||||||
const io = getInstance();
|
io.getInstance()?.emit("FileDelete", { pathname });
|
||||||
io?.emit("FileDelete", { pathname });
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -144,8 +143,9 @@ async function handleNotFoundRecord(
|
||||||
|
|
||||||
if (!result) return false;
|
if (!result) return false;
|
||||||
|
|
||||||
const io = getInstance();
|
if (!metadata.hidden) {
|
||||||
io?.emit("FileUpload", metadata);
|
io.getInstance()?.emit("FileUpload", metadata);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -170,8 +170,9 @@ async function handleFoundRecord(
|
||||||
|
|
||||||
if (!result) return false;
|
if (!result) return false;
|
||||||
|
|
||||||
const io = getInstance();
|
if (!metadata.hidden) {
|
||||||
io?.emit("FileUpload", metadata);
|
io.getInstance()?.emit("FileUpload", metadata);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue