fix: upload not working in a folder that's a Windows drive root
Massimo Melina committed
Sep 27, 2024 at 12:07 UTC
f5406bb556c4eddcc0fdfe23b6f73eb097bab714
1 file changed
+5
-3
src/upload.ts
+5
-3
@@ -4,8 +4,10 @@ import { HTTP_CONFLICT, HTTP_FOOL, HTTP_PAYLOAD_TOO_LARGE, HTTP_RANGE_NOT_SATISF
4
HTTP_BAD_REQUEST } from './const'
5
import { basename, dirname, extname, join } from 'path'
6
import fs from 'fs'
7
-import { Callback, dirTraversal, loadFileAttr, pendingPromise, storeFileAttr, try_,
8
- createStreamLimiter, } from './misc'
7
+import {
8
+ Callback, dirTraversal, loadFileAttr, pendingPromise, storeFileAttr, try_,
9
+ createStreamLimiter, isWindowsDrive,
10
+} from './misc'
11
import { notifyClient } from './frontEndApis'
12
import { defineConfig } from './config'
13
import { getDiskSpaceSync } from './util-os'
@@ -89,7 +91,7 @@ export function uploadWriter(base: VfsNode, path: string, ctx: Koa.Context) {
91
openFiles.add(fullPath)
92
try {
93
// if upload creates a folder, then add meta to it too
92
- if (fs.mkdirSync(dir, { recursive: true }))
94
+ if (!dir.endsWith(':\\') && fs.mkdirSync(dir, { recursive: true }))
95
setUploadMeta(dir, ctx)
96
// use temporary name while uploading
97
const keepName = basename(fullPath).slice(-200)