diff --git a/Services/server/src/controllers/cabinetController.ts b/Services/server/src/controllers/cabinetController.ts index 40af2d5..27ac346 100644 --- a/Services/server/src/controllers/cabinetController.ts +++ b/Services/server/src/controllers/cabinetController.ts @@ -114,7 +114,8 @@ export class CabinetController extends Controller { list.map(async (current) => { if (!current.name) return; - const destination = `${replaceIllegalChars(body.name)}/${current.name.slice(path.length)}`; + const base = `${replaceIllegalChars(body.name)}/`; + const destination = `${base}${current.name.slice(path.length)}`; const source = `/${DEFAULT_BUCKET}/${current.name}`; return await minioClient @@ -138,7 +139,7 @@ export class CabinetController extends Controller { await esClient.update({ index: DEFAULT_INDEX!, id: data._id, - doc: { pathname: destination, path }, + doc: { pathname: destination, path: destination.split("/").splice(0, -1).join("/") }, refresh: "wait_for", }); diff --git a/Services/server/src/controllers/drawerController.ts b/Services/server/src/controllers/drawerController.ts index 3c30b97..f851ee9 100644 --- a/Services/server/src/controllers/drawerController.ts +++ b/Services/server/src/controllers/drawerController.ts @@ -131,9 +131,8 @@ export class DrawerController extends Controller { list.map(async (current) => { if (!current.name) return; - const destination = `${cabinetName}/${replaceIllegalChars(body.name)}/${current.name.slice( - path.length, - )}`; + const base = `${cabinetName}/${replaceIllegalChars(body.name)}/`; + const destination = `${base}${current.name.slice(path.length)}`; const source = `/${DEFAULT_BUCKET}/${current.name}`; return await minioClient @@ -157,7 +156,7 @@ export class DrawerController extends Controller { await esClient.update({ index: DEFAULT_INDEX!, id: data._id, - doc: { pathname: destination, path }, + doc: { pathname: destination, path: destination.split("/").splice(0, -1).join("/") }, refresh: "wait_for", }); diff --git a/Services/server/src/controllers/folderController.ts b/Services/server/src/controllers/folderController.ts index 05c2e67..d49ca91 100644 --- a/Services/server/src/controllers/folderController.ts +++ b/Services/server/src/controllers/folderController.ts @@ -138,9 +138,8 @@ export class FolderController extends Controller { list.map(async (current) => { if (!current.name) return; - const destination = `${cabinetName}/${drawerName}/${replaceIllegalChars( - body.name, - )}/${current.name.slice(path.length)}`; + const base = `${cabinetName}/${drawerName}/${replaceIllegalChars(body.name)}/`; + const destination = `${base}${current.name.slice(path.length)}`; const source = `/${DEFAULT_BUCKET}/${current.name}`; return await minioClient @@ -164,7 +163,7 @@ export class FolderController extends Controller { await esClient.update({ index: DEFAULT_INDEX!, id: data._id, - doc: { pathname: destination, path }, + doc: { pathname: destination, path: destination.split("/").splice(0, -1).join("/") }, refresh: "wait_for", }); diff --git a/Services/server/src/controllers/subFolderController.ts b/Services/server/src/controllers/subFolderController.ts index fb81506..c2ee699 100644 --- a/Services/server/src/controllers/subFolderController.ts +++ b/Services/server/src/controllers/subFolderController.ts @@ -139,9 +139,10 @@ export class SubFolderController extends Controller { list.map(async (current) => { if (!current.name) return; - const destination = `${cabinetName}/${drawerName}/${folderName}/${replaceIllegalChars( + const base = `${cabinetName}/${drawerName}/${folderName}/${replaceIllegalChars( body.name, - )}/${current.name.slice(path.length)}`; + )}/`; + const destination = `${base}${current.name.slice(path.length)}`; const source = `/${DEFAULT_BUCKET}/${current.name}`; return await minioClient @@ -165,7 +166,7 @@ export class SubFolderController extends Controller { await esClient.update({ index: DEFAULT_INDEX!, id: data._id, - doc: { pathname: destination, path }, + doc: { pathname: destination, path: destination.split("/").splice(0, -1).join("/") }, refresh: "wait_for", });