fix: (regression 0.57.0) faulty split-uploads

Massimo Melina committed May 1, 2025 at 10:23 UTC 3f5e8465d535f55118ed152a6844fcdd214a120a
2 files changed +5 -4
src/serveGuiAndSharedFiles.ts
+2 -2
@@ -72,8 +72,8 @@ export const serveGuiAndSharedFiles: Koa.Middleware = async (ctx, next) => {
72 const uri = await dest.lockMiddleware // we need to wait more than just the stream
73 if (uri) // falsy = aborted
74 ctx.body = { uri }
75 - else
76 - ctx.status = 400 // nodejs already sent 400, but koa ignores it (ctx.headersSent is false and ctx.status is 404), so we adjust to have correct data in the log
75 + else if (ctx.status === 404) // nodejs already sent 400, but koa ignores it (ctx.headersSent is false and ctx.status is 404), so we adjust koa state to have correct data in the log
76 + ctx.status = 400
77 }
78 return
79 }
src/upload.ts
+3 -2
@@ -2,7 +2,7 @@ import { getNodeByName, statusCodeForMissingPerm, VfsNode } from './vfs'
2 import Koa from 'koa'
3 import {
4 HTTP_CONFLICT, HTTP_FOOL, HTTP_INSUFFICIENT_STORAGE, HTTP_RANGE_NOT_SATISFIABLE, HTTP_BAD_REQUEST,
5 - UPLOAD_RESUMABLE, UPLOAD_REQUEST_STATUS, UPLOAD_RESUMABLE_HASH,
5 + UPLOAD_RESUMABLE, UPLOAD_REQUEST_STATUS, UPLOAD_RESUMABLE_HASH, HTTP_NO_CONTENT,
6 } from './const'
7 import { basename, dirname, extname, join } from 'path'
8 import fs from 'fs'
@@ -196,7 +196,8 @@ export function uploadWriter(base: VfsNode, baseUri: string, path: string, ctx:
196 const sec = deleteUnfinishedUploadsAfter.get()
197 return _.isNumber(sec) && delayedDelete(tempName, sec)
198 }
199 - if (ctx.query.partial) return // this upload is partial, and we are supposed to leave the upload as unfinished, with the temp name
199 + if (ctx.query.partial) // this upload is partial, and we are supposed to leave the upload as unfinished, with the temp name
200 + return ctx.status = HTTP_NO_CONTENT // lockMiddleware contains an empty string, so we must take care of the status
201 let dest = fullPath
202 if (dontOverwriteUploading.get() && !await overwriteAnyway() && fs.existsSync(dest)) {
203 if (overwriteRequestedButForbidden) {