Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

fix(backend:files): handle axios content-length header as number-safe value

johaven3599ccb5a041
diff --git a/backend/src/applications/files/modules/only-office/only-office-manager.service.ts b/backend/src/applications/files/modules/only-office/only-office-manager.service.ts
index 7071bcb2..ef6c7fce 100644
--- a/backend/src/applications/files/modules/only-office/only-office-manager.service.ts
+++ b/backend/src/applications/files/modules/only-office/only-office-manager.service.ts
@@ -359,7 +359,7 @@ export class OnlyOfficeManager {
}
// try to verify the downloaded size
- const contentLength = parseInt(res.headers['content-length'], 10)
+ const contentLength = Number(res.headers['content-length'])
if (!isNaN(contentLength) && contentLength !== 0) {
const tmpFileSize = await fileSize(tmpFilePath)
if (tmpFileSize !== contentLength) {
diff --git a/backend/src/applications/files/services/files-manager.service.ts b/backend/src/applications/files/services/files-manager.service.ts
index dc56c63e..ce8f4c58 100644
--- a/backend/src/applications/files/services/files-manager.service.ts
+++ b/backend/src/applications/files/services/files-manager.service.ts
@@ -535,7 +535,7 @@ export class FilesManager {
// attempt to retrieve the Content-Length header
try {
if ('content-length' in headRes.headers) {
- space.task.props.totalSize = parseInt(headRes.headers['content-length'], 10) || null
+ space.task.props.totalSize = Number(headRes.headers['content-length']) || null
}
} catch (e) {
this.logger.debug({ tag: this.downloadFromUrl.name, msg: `content-length : ${e}` })