From 728e9eea2dad5eabd14de01e75b89df484c20ac6 Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Sat, 25 Jan 2025 19:43:57 +0000 Subject: [PATCH] fix paths & use async rm --- .../server/services/files/routes/upload/chunk/post.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/server/services/files/routes/upload/chunk/post.js b/packages/server/services/files/routes/upload/chunk/post.js index d37bffca..fd91a225 100644 --- a/packages/server/services/files/routes/upload/chunk/post.js +++ b/packages/server/services/files/routes/upload/chunk/post.js @@ -13,9 +13,7 @@ export default { "withAuthentication", ], fn: async (req, res) => { - const userPath = path.join(this.default.contexts.cache.constructor.cachePath, req.auth.session.user_id) - - const tmpPath = path.resolve(userPath) + const tmpPath = path.resolve(this.default.contexts.cache.constructor.cachePath, req.auth.session.user_id) const limits = { maxFileSize: parseInt(this.default.contexts.limits.maxFileSizeInMB) * 1024 * 1024, @@ -62,13 +60,13 @@ export default { cachePath: tmpPath, }) - fs.promises.rm(tmpPath, { recursive: true, force: true }).catch(() => { + await fs.promises.rm(tmpPath, { recursive: true, force: true }).catch(() => { return false }) return result } catch (error) { - fs.promises.rm(tmpPath, { recursive: true, force: true }).catch(() => { + await fs.promises.rm(tmpPath, { recursive: true, force: true }).catch(() => { return false }) @@ -77,7 +75,8 @@ export default { } return { - ok: 1 + ok: 1, + chunkNumber: req.headers["uploader-chunk-number"], } } } \ No newline at end of file