@nger/fk-upload 1.0.49 → 1.0.52

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.
@@ -37,12 +37,15 @@ class DownloadTask extends rabbitmq_1.Task {
37
37
  });
38
38
  let total = 0;
39
39
  let length = 0;
40
- let md5 = ``;
41
40
  console.log(`download ${url}`);
42
41
  const sub = new rxjs_1.Subject();
43
42
  sub.pipe((0, operators_1.throttleTime)(1000), (0, operators_1.switchMap)((size) => {
44
- return db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, { size });
45
- })).subscribe();
43
+ return db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, { totalSize: total, size });
44
+ })).subscribe({
45
+ next: () => { },
46
+ complete: () => {
47
+ }
48
+ });
46
49
  // get split size
47
50
  req.on('data', (buf) => {
48
51
  length += buf.length;
@@ -56,8 +59,7 @@ class DownloadTask extends rabbitmq_1.Task {
56
59
  writeStream.end();
57
60
  sub.complete();
58
61
  const fileMd5 = await (0, md5_file_1.default)(task.path);
59
- const isEqual = md5 === fileMd5;
60
- console.log(`file download success ${task.filename}, check result is ${isEqual}`);
62
+ console.log(`file download success ${task.filename}: ${fileMd5}`);
61
63
  const uploadTask = await this.createUploadTask(task, total, fileMd5, injector);
62
64
  await manager.send(uploadTask);
63
65
  complete();
@@ -71,7 +73,7 @@ class DownloadTask extends rabbitmq_1.Task {
71
73
  }
72
74
  async createUploadTask(download, total, md5, injector) {
73
75
  const db = injector.get(typeorm_1.Db);
74
- await db.manager.update(entities_1.FkDownloadTaskEntity, download.filename, { totalSize: total, status: 1, size: total });
76
+ await db.manager.update(entities_1.FkDownloadTaskEntity, download.filename, { totalSize: total, fileMd5: md5, status: 1, size: total });
75
77
  const fk = injector.get(fk_service_1.FkService);
76
78
  const info = await fk.getUploadInfo(download.loginId, download.filename, md5, total);
77
79
  if (info) {
@@ -139,7 +139,6 @@ let FkService = class FkService {
139
139
  },
140
140
  timeout: 8000
141
141
  }).then(res => {
142
- // console.log(`upload success`, { data: res.data, start, end, index, total: task.totalChunks })
143
142
  return res.data;
144
143
  }).catch(async (e) => {
145
144
  const info = await this.getUploadInfo(task.loginId, task.filename, task.fileMd5, task.total);
@@ -159,13 +158,13 @@ let FkService = class FkService {
159
158
  const data = uploadResult.data;
160
159
  const downUrl = data.path;
161
160
  if (downUrl) {
162
- console.log({
163
- data
164
- });
165
161
  const fullUrl = downUrl.startsWith('http') ? downUrl : `https:` + downUrl;
166
162
  task.uploadUrl = fullUrl;
167
163
  }
168
164
  }
165
+ if (index === task.totalChunks) {
166
+ console.log(uploadResult);
167
+ }
169
168
  console.log(`uploading ${index / task.totalChunks}`);
170
169
  index = index + 1;
171
170
  } while (!complete);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nger/fk-upload",
3
- "version": "1.0.49",
3
+ "version": "1.0.52",
4
4
  "description": "",
5
5
  "main": "dist/core.js",
6
6
  "types": "dist/core.d.ts",