@nger/fk-upload 1.0.51 → 1.0.55
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,7 @@ 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");
|
8
9
|
class EffectTask extends rabbitmq_1.Task {
|
9
10
|
constructor() {
|
10
11
|
super(actions_1.EFFECT_ACTION);
|
@@ -15,7 +16,7 @@ class EffectTask extends rabbitmq_1.Task {
|
|
15
16
|
const fail = injector.get(rabbitmq_1.FAIL);
|
16
17
|
const w7 = injector.get(w7_1.W7DataSource);
|
17
18
|
const db = injector.get(typeorm_1.Db);
|
18
|
-
|
19
|
+
await db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, { status: 3 });
|
19
20
|
// if (task.topicId) {
|
20
21
|
// await unlink(task.path);
|
21
22
|
// await w7.manager.update(W7ChatTopicEntity, task.topicId, { thirdUrl: task.uploadUrl }).then(() => complete()).catch(() => fail())
|
@@ -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);
|
@@ -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());
|