@nger/fk-upload 1.0.59 → 1.0.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -141,30 +141,14 @@ let FkService = class FkService {
|
|
141
141
|
}).then(res => {
|
142
142
|
return res.data;
|
143
143
|
}).catch(async (e) => {
|
144
|
-
|
145
|
-
task.cookies = info.cookies;
|
146
|
-
task.splitSize = info.splitSize;
|
147
|
-
task.start = info.uploadedSize;
|
148
|
-
task.uploadUrl = info.uploadUrl;
|
149
|
-
task.index = Math.ceil(info.uploadedSize / info.splitSize);
|
150
|
-
console.log(info);
|
151
|
-
await this.uploadFile(task);
|
152
|
-
return;
|
144
|
+
throw e;
|
153
145
|
});
|
154
146
|
if (!uploadResult) {
|
155
147
|
complete = true;
|
156
148
|
break;
|
157
149
|
}
|
158
150
|
if (uploadResult.code !== 200) {
|
159
|
-
|
160
|
-
const info = await this.getUploadInfo(task.loginId, task.filename, task.fileMd5, task.total);
|
161
|
-
task.cookies = info.cookies;
|
162
|
-
task.splitSize = info.splitSize;
|
163
|
-
task.start = info.uploadedSize;
|
164
|
-
task.uploadUrl = info.uploadUrl;
|
165
|
-
task.index = Math.ceil(info.uploadedSize / info.splitSize);
|
166
|
-
await this.uploadFile(task);
|
167
|
-
return;
|
151
|
+
throw new Error(uploadResult.code);
|
168
152
|
}
|
169
153
|
if (uploadResult) {
|
170
154
|
const data = uploadResult.data;
|
@@ -177,7 +161,7 @@ let FkService = class FkService {
|
|
177
161
|
task.uploadUrl = fullUrl;
|
178
162
|
}
|
179
163
|
}
|
180
|
-
console.log(`uploading ${index / task.totalChunks}
|
164
|
+
console.log(`uploading ${Math.floor((index + 1 / task.totalChunks) * 100)}%`);
|
181
165
|
index = index + 1;
|
182
166
|
} while (!complete);
|
183
167
|
// upload complete
|
@@ -19,12 +19,16 @@ class UploadTask extends rabbitmq_1.Task {
|
|
19
19
|
const taskService = injector.get(task_service_1.TaskService);
|
20
20
|
const manager = injector.get(rabbitmq_1.TaskManager);
|
21
21
|
const db = injector.get(typeorm_1.Db);
|
22
|
+
// > 1G give up
|
23
|
+
if (task.total >= 1024 * 1024 * 1024) {
|
24
|
+
complete();
|
25
|
+
}
|
22
26
|
await fk.startUploadFile(task).then(async (res) => {
|
23
27
|
// create effect task
|
24
28
|
await db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, { status: 2, uploadUrl: task.uploadUrl, uploadSize: task.total, uploadStatus: 1 });
|
25
29
|
const effectTask = await taskService.createEffectTask(task.filename, task.uploadUrl, task.topicId, task.path);
|
26
|
-
return manager.send(effectTask).then(() => complete())
|
27
|
-
})
|
30
|
+
return manager.send(effectTask).then(() => complete());
|
31
|
+
});
|
28
32
|
if (next)
|
29
33
|
await next();
|
30
34
|
}
|