@nger/fk-upload 1.0.50 → 1.0.53

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.
@@ -73,7 +73,7 @@ class DownloadTask extends rabbitmq_1.Task {
73
73
  }
74
74
  async createUploadTask(download, total, md5, injector) {
75
75
  const db = injector.get(typeorm_1.Db);
76
- 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 });
77
77
  const fk = injector.get(fk_service_1.FkService);
78
78
  const info = await fk.getUploadInfo(download.loginId, download.filename, md5, total);
79
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);
@@ -155,17 +154,28 @@ let FkService = class FkService {
155
154
  complete = true;
156
155
  break;
157
156
  }
157
+ if (uploadResult.code !== 200) {
158
+ console.log(uploadResult);
159
+ const info = await this.getUploadInfo(task.loginId, task.filename, task.fileMd5, task.total);
160
+ task.cookies = info.cookies;
161
+ task.splitSize = info.splitSize;
162
+ task.start = info.uploadedSize;
163
+ task.uploadUrl = info.uploadUrl;
164
+ task.index = Math.ceil(info.uploadedSize / info.splitSize);
165
+ await this.uploadFile(task);
166
+ return;
167
+ }
158
168
  if (uploadResult) {
159
169
  const data = uploadResult.data;
160
170
  const downUrl = data.path;
161
171
  if (downUrl) {
162
- console.log({
163
- data
164
- });
165
172
  const fullUrl = downUrl.startsWith('http') ? downUrl : `https:` + downUrl;
166
173
  task.uploadUrl = fullUrl;
167
174
  }
168
175
  }
176
+ if (index === task.totalChunks) {
177
+ console.log(uploadResult);
178
+ }
169
179
  console.log(`uploading ${index / task.totalChunks}`);
170
180
  index = index + 1;
171
181
  } while (!complete);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nger/fk-upload",
3
- "version": "1.0.50",
3
+ "version": "1.0.53",
4
4
  "description": "",
5
5
  "main": "dist/core.js",
6
6
  "types": "dist/core.d.ts",