better error code for uploads missing space
Massimo Melina committed
Mar 2, 2025 at 19:49 UTC
67d0bc6314b5d64a251e41aa4af7e394045233e1
2 files changed
+3
-2
src/cross-const.ts
+1
@@ -34,6 +34,7 @@ export const HTTP_FAILED_DEPENDENCY = 424
34
export const HTTP_TOO_MANY_REQUESTS = 429
35
export const HTTP_SERVER_ERROR = 500
36
export const HTTP_SERVICE_UNAVAILABLE = 503
37
+export const HTTP_INSUFFICIENT_STORAGE = 507
38
39
export const HTTP_MESSAGES: Record<number, string> = {
40
[HTTP_UNAUTHORIZED]: "Unauthorized",
src/upload.ts
+2
-2
@@ -1,7 +1,7 @@
1
import { getNodeByName, statusCodeForMissingPerm, VfsNode } from './vfs'
2
import Koa from 'koa'
3
import {
4
- HTTP_CONFLICT, HTTP_FOOL, HTTP_PAYLOAD_TOO_LARGE, HTTP_RANGE_NOT_SATISFIABLE, HTTP_BAD_REQUEST,
4
+ HTTP_CONFLICT, HTTP_FOOL, HTTP_INSUFFICIENT_STORAGE, HTTP_RANGE_NOT_SATISFIABLE, HTTP_BAD_REQUEST,
5
UPLOAD_RESUMABLE, UPLOAD_REQUEST_STATUS, UPLOAD_RESUMABLE_HASH,
6
} from './const'
7
import { basename, dirname, extname, join } from 'path'
@@ -109,7 +109,7 @@ export function uploadWriter(base: VfsNode, baseUri: string, path: string, ctx:
109
if (typeof free !== 'number' || isNaN(free))
110
throw ''
111
if (fullSize > free - (min || 0))
112
- return fail(HTTP_PAYLOAD_TOO_LARGE)
112
+ return fail(HTTP_INSUFFICIENT_STORAGE)
113
}
114
catch(e: any) { // warn, but let it through
115
console.warn("can't check disk size:", e.message || String(e))