@nger/fk-upload 1.0.72 → 1.0.73

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.
@@ -13,4 +13,5 @@ export declare class CheckUploadController {
13
13
  msg: string;
14
14
  list: TaskEntity<object>[];
15
15
  }>;
16
+ checkSpace(): Promise<void>;
16
17
  }
@@ -2,10 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CheckUploadController = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const fs_1 = require("fs");
6
+ const fk_download_task_entity_1 = require("./../entities/fk-download-task.entity");
5
7
  const rabbitmq_1 = require("@nger/rabbitmq");
6
8
  const typeorm_1 = require("@nger/typeorm");
7
9
  const core_1 = require("@nger/core");
8
10
  const http_1 = require("@nger/http");
11
+ const typeorm_2 = require("typeorm");
12
+ const fs_extra_1 = require("fs-extra");
9
13
  let CheckUploadController = class CheckUploadController {
10
14
  db;
11
15
  manager;
@@ -31,6 +35,15 @@ let CheckUploadController = class CheckUploadController {
31
35
  await Promise.all(list.map(item => this.manager.send(item)));
32
36
  return { msg: 'recheck success', list };
33
37
  }
38
+ async checkSpace() {
39
+ const download = this.db.manager.getRepository(fk_download_task_entity_1.FkDownloadTaskEntity);
40
+ const list = await download.find({ where: { status: (0, typeorm_2.In)([2, 3]) } });
41
+ list.map(item => {
42
+ if ((0, fs_1.existsSync)(item.path)) {
43
+ (0, fs_extra_1.unlink)(item.path);
44
+ }
45
+ });
46
+ }
34
47
  };
35
48
  tslib_1.__decorate([
36
49
  (0, http_1.Get)('reupload'),
@@ -50,6 +63,12 @@ tslib_1.__decorate([
50
63
  tslib_1.__metadata("design:paramtypes", []),
51
64
  tslib_1.__metadata("design:returntype", Promise)
52
65
  ], CheckUploadController.prototype, "redownload", null);
66
+ tslib_1.__decorate([
67
+ (0, http_1.Get)('checkspace'),
68
+ tslib_1.__metadata("design:type", Function),
69
+ tslib_1.__metadata("design:paramtypes", []),
70
+ tslib_1.__metadata("design:returntype", Promise)
71
+ ], CheckUploadController.prototype, "checkSpace", null);
53
72
  CheckUploadController = tslib_1.__decorate([
54
73
  (0, core_1.Controller)(`@nger/fk-upload`),
55
74
  tslib_1.__metadata("design:paramtypes", [typeorm_1.Db, rabbitmq_1.TaskManager])
@@ -67,6 +67,7 @@ class DownloadTask extends rabbitmq_1.Task {
67
67
  const uploadTask = await this.createUploadTask(task, total, fileMd5, injector);
68
68
  await manager.send(uploadTask);
69
69
  complete();
70
+ this.downloadingCount -= 1;
70
71
  });
71
72
  req.on('response', async (resp) => {
72
73
  const headers = resp.headers;
@@ -75,6 +76,7 @@ class DownloadTask extends rabbitmq_1.Task {
75
76
  console.log(`file is to large`);
76
77
  req.destroy();
77
78
  complete();
79
+ this.downloadingCount -= 1;
78
80
  }
79
81
  });
80
82
  if (next)
@@ -44,7 +44,8 @@ class UploadTask extends rabbitmq_1.Task {
44
44
  console.log(`upload success`, res.filename);
45
45
  await db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, { status: 2, uploadUrl: task.uploadUrl, uploadSize: task.total, uploadStatus: 1 });
46
46
  const effectTask = await taskService.createEffectTask(res.filename, res.uploadUrl, task.topicId, task.path);
47
- return manager.send(effectTask).then(() => complete());
47
+ await manager.send(effectTask).then(() => complete());
48
+ this.runingCount -= 1;
48
49
  });
49
50
  }
50
51
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nger/fk-upload",
3
- "version": "1.0.72",
3
+ "version": "1.0.73",
4
4
  "description": "",
5
5
  "main": "dist/core.js",
6
6
  "types": "dist/core.d.ts",