@nger/fk-upload 1.0.30 → 1.0.33

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.
@@ -62,6 +62,7 @@ export declare class TaskService {
62
62
  private getUploadInfourl;
63
63
  private encodeURIComponent;
64
64
  private getUploadUrl;
65
+ reUploadTask(): Promise<void>;
65
66
  startUploadTask(filename: string): Promise<void>;
66
67
  download(task: DownloadTask): Observable<DownloadTask>;
67
68
  }
@@ -60,8 +60,7 @@ let TaskService = class TaskService {
60
60
  this.redis.set(filename, `0`);
61
61
  }
62
62
  async addEffectTask(task) {
63
- const content = Buffer.from(JSON.stringify(task));
64
- await this.rabbit.send('@nger/fk-upload/effect-task', content);
63
+ // const content = Buffer.from(JSON.stringify(task)); // await this.rabbit.send('@nger/fk-upload/effect-task', content)
65
64
  }
66
65
  async addScheduleTask(task) {
67
66
  const content = Buffer.from(JSON.stringify(task));
@@ -203,54 +202,59 @@ let TaskService = class TaskService {
203
202
  total: task.total
204
203
  }
205
204
  });
206
- this.redis.set(task.filename, `${task.index + 1}`);
207
- if (data) {
208
- // fullDownUrl
209
- const downUrl = data.path;
210
- if (downUrl) {
211
- const fullUrl = downUrl.startsWith('http') ? downUrl : `https:` + downUrl;
212
- axios_1.default.post(`https://smr00.vip.webportal.top/ajax/advanceUpload.jsp?cmd=_report&_TOKEN=${task.token}`, this.encodeURIComponent({
213
- type: 1,
214
- size: task.total,
215
- time: NaN,
216
- flag: true,
217
- name: task.filename
218
- }), {
219
- headers: {
220
- [`Content-Type`]: `application/x-www-form-urlencoded; charset=UTF-8`,
221
- Cookie: task.cookies
222
- }
223
- });
224
- this.redis.del(task.filename);
225
- this.ws.send({
226
- action: `@nger/fk-upload/uploading`,
227
- data: {
228
- uploadSize: task.end,
205
+ this.redis.set(task.filename, `${task.index + 1}`, (err) => {
206
+ if (err)
207
+ return fail();
208
+ if (data) {
209
+ // fullDownUrl
210
+ const downUrl = data.path;
211
+ if (downUrl) {
212
+ const fullUrl = downUrl.startsWith('http') ? downUrl : `https:` + downUrl;
213
+ axios_1.default.post(`https://smr00.vip.webportal.top/ajax/advanceUpload.jsp?cmd=_report&_TOKEN=${task.token}`, this.encodeURIComponent({
214
+ type: 1,
215
+ size: task.total,
216
+ time: NaN,
217
+ flag: true,
218
+ name: task.filename
219
+ }), {
220
+ headers: {
221
+ [`Content-Type`]: `application/x-www-form-urlencoded; charset=UTF-8`,
222
+ Cookie: task.cookies
223
+ }
224
+ });
225
+ this.redis.del(task.filename, () => {
226
+ complete();
227
+ });
228
+ this.ws.send({
229
+ action: `@nger/fk-upload/uploading`,
230
+ data: {
231
+ uploadSize: task.end,
232
+ filename: task.filename,
233
+ total: task.total,
234
+ uploadUrl: fullUrl
235
+ }
236
+ });
237
+ this.addEffectTask({
229
238
  filename: task.filename,
230
- total: task.total,
231
- uploadUrl: fullUrl
232
- }
233
- });
234
- this.addEffectTask({
235
- filename: task.filename,
236
- uploadUrl: fullUrl,
237
- topicId: task.topicId
238
- });
239
- this.db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, {
240
- status: 2,
241
- uploadUrl: fullUrl,
242
- uploadSize: task.total
243
- }).then(() => complete()).catch(() => fail());
239
+ uploadUrl: fullUrl,
240
+ topicId: task.topicId
241
+ });
242
+ this.db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, {
243
+ status: 2,
244
+ uploadUrl: fullUrl,
245
+ uploadSize: task.total
246
+ });
247
+ }
248
+ else {
249
+ this.db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, {
250
+ uploadSize: task.end
251
+ });
252
+ }
244
253
  }
245
254
  else {
246
- this.db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, {
247
- uploadSize: task.end
248
- }).then(() => complete()).catch(() => fail());
255
+ console.log(`data is empty`, uploadResult);
249
256
  }
250
- }
251
- else {
252
- fail();
253
- }
257
+ });
254
258
  }
255
259
  else {
256
260
  fail();
@@ -330,6 +334,7 @@ let TaskService = class TaskService {
330
334
  return `https://${token.url}/${token.visitType}/${token.app}/advance?cmd=${token.cmd}&token=${token.token}`;
331
335
  }
332
336
  }
337
+ async reUploadTask() { }
333
338
  async startUploadTask(filename) {
334
339
  const task = await this.db.manager.findOne(entities_1.FkDownloadTaskEntity, { where: { filename } });
335
340
  if (task && task.status === 1) {
@@ -374,12 +379,12 @@ let TaskService = class TaskService {
374
379
  const { delayTime, splitSize, uploadedSize } = data;
375
380
  const uploadUrl = this.getUploadUrl(accessToken, false);
376
381
  const totalChunks = Math.ceil((task.totalSize) / splitSize);
377
- let start = 0;
378
- let index = 0;
382
+ let start = uploadedSize + 1;
383
+ let index = Math.ceil(uploadedSize / splitSize);
379
384
  let complete = false;
380
385
  this.beginUploadTask(task.filename);
381
386
  do {
382
- const maxEndSize = start + splitSize;
387
+ const maxEndSize = start + 1 + splitSize;
383
388
  if (index >= totalChunks - 1 || maxEndSize >= task.totalSize) {
384
389
  complete = true;
385
390
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nger/fk-upload",
3
- "version": "1.0.30",
3
+ "version": "1.0.33",
4
4
  "description": "",
5
5
  "main": "dist/core.js",
6
6
  "types": "dist/core.d.ts",