@nger/fk-upload 1.0.115 → 1.0.118

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.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CheckUploadController = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const fk_service_1 = require("./tasks/fk.service");
5
6
  const fs_1 = require("fs");
6
7
  const fk_download_task_entity_1 = require("./../entities/fk-download-task.entity");
7
8
  const rabbitmq_1 = require("@nger/rabbitmq");
@@ -89,7 +90,11 @@ let CheckUploadController = class CheckUploadController {
89
90
  }
90
91
  const list = await download.find({ where: { status: 1, totalSize: (0, typeorm_2.LessThan)(1024 * 1024 * 1024) } });
91
92
  const task = this.injector.get(task_service_1.TaskService);
93
+ const fk = this.injector.get(fk_service_1.FkService);
92
94
  await Promise.all(list.map(async (item) => {
95
+ const cloudSize = await fk.getSize(item.url);
96
+ const localSize = fk.getLocalSize(item.path);
97
+ console.log({ cloudSize, localSize });
93
98
  const upload = await task.createUploadTask({
94
99
  filename: item.filename,
95
100
  path: item.path,
@@ -169,6 +169,7 @@ let FkService = class FkService {
169
169
  });
170
170
  if (!uploadResult) {
171
171
  complete = true;
172
+ index = 0;
172
173
  break;
173
174
  }
174
175
  if (uploadResult.code !== 200) {
@@ -193,9 +194,9 @@ let FkService = class FkService {
193
194
  task.uploadUrl = fullUrl;
194
195
  }
195
196
  }
196
- // console.log(`uploading ${task.filename} ${Math.floor((index + 1 / task.totalChunks))}%`)
197
197
  index = index + 1;
198
198
  } while (!complete);
199
+ console.log(`uploading ${task.filename} ${task.uploadUrl}`);
199
200
  index = 0;
200
201
  // upload complete
201
202
  axios_1.default.post(`https://smr00.vip.webportal.top/ajax/advanceUpload.jsp?cmd=_report&_TOKEN=${task.token}`, this.encodeURIComponent({
@@ -50,7 +50,8 @@ class UploadTask extends rabbitmq_1.Task {
50
50
  await complete();
51
51
  return next && next();
52
52
  }
53
- if (old.status === 1) {
53
+ console.log(`receive upload task`, { filename: task.filename, status: old.status });
54
+ if (old.status == 1) {
54
55
  // upload
55
56
  await fk.startUploadFile(task).then(async (res) => {
56
57
  // create effect task
@@ -65,7 +66,7 @@ class UploadTask extends rabbitmq_1.Task {
65
66
  }
66
67
  if (this.errorCount > 10) {
67
68
  this.errorCount = 0;
68
- return await complete();
69
+ return complete();
69
70
  }
70
71
  this.errorCount += 1;
71
72
  throw e;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nger/fk-upload",
3
- "version": "1.0.115",
3
+ "version": "1.0.118",
4
4
  "description": "",
5
5
  "main": "dist/core.js",
6
6
  "types": "dist/core.d.ts",