@nger/fk-upload 1.0.52 → 1.0.56
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.
@@ -5,6 +5,8 @@ const rabbitmq_1 = require("@nger/rabbitmq");
|
|
5
5
|
const actions_1 = require("./actions");
|
6
6
|
const typeorm_1 = require("@nger/typeorm");
|
7
7
|
const w7_1 = require("@nger/w7");
|
8
|
+
const entities_1 = require("../../entities");
|
9
|
+
const fs_extra_1 = require("fs-extra");
|
8
10
|
class EffectTask extends rabbitmq_1.Task {
|
9
11
|
constructor() {
|
10
12
|
super(actions_1.EFFECT_ACTION);
|
@@ -15,13 +17,15 @@ class EffectTask extends rabbitmq_1.Task {
|
|
15
17
|
const fail = injector.get(rabbitmq_1.FAIL);
|
16
18
|
const w7 = injector.get(w7_1.W7DataSource);
|
17
19
|
const db = injector.get(typeorm_1.Db);
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
await db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, { status: 3 });
|
21
|
+
if (task.topicId) {
|
22
|
+
await (0, fs_extra_1.unlink)(task.path);
|
23
|
+
await w7.manager.update(w7_1.W7ChatTopicEntity, task.topicId, { thirdUrl: task.uploadUrl }).then(() => complete()).catch(() => fail());
|
24
|
+
complete();
|
25
|
+
}
|
26
|
+
else {
|
27
|
+
complete();
|
28
|
+
}
|
25
29
|
if (next)
|
26
30
|
await next();
|
27
31
|
}
|
@@ -154,6 +154,17 @@ let FkService = class FkService {
|
|
154
154
|
complete = true;
|
155
155
|
break;
|
156
156
|
}
|
157
|
+
if (uploadResult.code !== 200) {
|
158
|
+
console.log(uploadResult, { size: end - start });
|
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
|
+
}
|
157
168
|
if (uploadResult) {
|
158
169
|
const data = uploadResult.data;
|
159
170
|
const downUrl = data.path;
|
@@ -21,7 +21,7 @@ class UploadTask extends rabbitmq_1.Task {
|
|
21
21
|
const db = injector.get(typeorm_1.Db);
|
22
22
|
await fk.startUploadFile(task).then(async (res) => {
|
23
23
|
// create effect task
|
24
|
-
await db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, { status: 2, uploadSize: task.total, uploadStatus: 1 });
|
24
|
+
await db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, { status: 2, uploadUrl: task.uploadUrl, uploadSize: task.total, uploadStatus: 1 });
|
25
25
|
const effectTask = await taskService.createEffectTask(task.filename, task.uploadUrl, task.topicId, task.path);
|
26
26
|
return manager.send(effectTask).then(() => complete()).catch(() => fail());
|
27
27
|
}).catch(() => fail());
|