Skip to content

Commit 6370b86

Browse files
committed
improve file upload to project by uploading files to ~/.smc/upload/, then moving them to project or compute server from there
- this is much better because you don't have a broken partial-upload in your face begging to be clicked on and cause trouble.
1 parent 1ae402b commit 6370b86

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/packages/project/upload.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ export default function init(): Router {
6666
}
6767

6868
try {
69-
const uploadDir = join(HOME, dest_dir);
70-
69+
const uploadDir = join(HOME, ".smc", "upload");
7170
// ensure target path exists
7271
dbg("ensure target path exists... ", uploadDir);
7372
await mkdir(uploadDir, { recursive: true });
@@ -113,7 +112,7 @@ export default function init(): Router {
113112
}
114113
*/
115114

116-
// Now, the strategy is to assemble to file chunk by chunk and save it with the original filename
115+
// Now, the strategy is to assemble the file chunk by chunk and save it with the original filename
117116
const chunkFullPath = files.file[0]?.filepath;
118117
const originalFn = files.file[0]?.originalFilename;
119118

@@ -124,6 +123,7 @@ export default function init(): Router {
124123
dbg(`uploading '${chunkFullPath}' -> '${originalFn}'`);
125124
}
126125

126+
const temp = join(uploadDir, originalFn);
127127
const dest = join(HOME, dest_dir, originalFn);
128128
dbg(`dest='${dest}'`);
129129
await ensureContainingDirectoryExists(dest);
@@ -133,6 +133,7 @@ export default function init(): Router {
133133
parseInt(fields.dzchunkindex),
134134
parseInt(fields.dztotalchunkcount),
135135
chunkFullPath,
136+
temp,
136137
dest,
137138
dest_dir,
138139
compute_server_id,
@@ -159,11 +160,11 @@ async function handle_chunk_data(
159160
index: number,
160161
total: number,
161162
chunk: string,
163+
temp: string,
162164
dest: string,
163165
dest_dir: string,
164166
compute_server_id: number,
165167
): Promise<void> {
166-
const temp = dest + ".partial-upload";
167168
if (index === 0) {
168169
// move chunk to the temp file
169170
await moveFile(chunk, temp);

0 commit comments

Comments
 (0)