@nger/fk-upload 1.0.64 → 1.0.65

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.
@@ -19,20 +19,28 @@ 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
+ const old = await db.manager.findOne(entities_1.FkDownloadTaskEntity, { where: { filename: task.filename } });
22
23
  // > 1G give up
23
24
  if (task.total >= 1024 * 1024 * 1024) {
24
25
  complete();
25
26
  }
26
27
  if (!(0, fs_1.existsSync)(task.path)) {
28
+ await db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, { status: 0 });
29
+ complete();
30
+ }
31
+ if (old.status === 1) {
32
+ // upload
33
+ await fk.startUploadFile(task).then(async (res) => {
34
+ // create effect task
35
+ console.log(`upload success`, res.filename);
36
+ await db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, { status: 2, uploadUrl: task.uploadUrl, uploadSize: task.total, uploadStatus: 1 });
37
+ const effectTask = await taskService.createEffectTask(res.filename, res.uploadUrl, task.topicId, task.path);
38
+ return manager.send(effectTask).then(() => complete());
39
+ });
40
+ }
41
+ else {
27
42
  complete();
28
43
  }
29
- await fk.startUploadFile(task).then(async (res) => {
30
- // create effect task
31
- console.log(`upload success`, res.filename);
32
- await db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, { status: 2, uploadUrl: task.uploadUrl, uploadSize: task.total, uploadStatus: 1 });
33
- const effectTask = await taskService.createEffectTask(res.filename, res.uploadUrl, task.topicId, task.path);
34
- return manager.send(effectTask).then(() => complete());
35
- });
36
44
  if (next)
37
45
  await next();
38
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nger/fk-upload",
3
- "version": "1.0.64",
3
+ "version": "1.0.65",
4
4
  "description": "",
5
5
  "main": "dist/core.js",
6
6
  "types": "dist/core.d.ts",