@nger/fk-upload 1.0.27 → 1.0.30
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.
@@ -70,15 +70,16 @@ let TaskService = class TaskService {
|
|
70
70
|
async createDownLoadTask(url, fkLoginId, topicId) {
|
71
71
|
const hash = await (0, multihashing_async_1.default)(Buffer.from(url), 'sha1', 16);
|
72
72
|
const cid = new cids_1.default(1, 'raw', hash, 'base64');
|
73
|
-
|
73
|
+
let filename = encodeURIComponent(cid.toString('base64'));
|
74
74
|
const _url = new URL(url);
|
75
75
|
const filePath = _url.pathname;
|
76
|
-
|
76
|
+
let ext = (0, path_1.extname)(filePath);
|
77
|
+
filename += ext === '.' ? '.mp4' : ext;
|
77
78
|
const task = new entities_1.FkDownloadTaskEntity();
|
78
79
|
const root = this.injector.get(core_1.APP_ROOT);
|
79
80
|
(0, fs_extra_1.ensureDirSync)((0, path_1.join)(root, 'attachments/fk-upload'));
|
80
|
-
const path = (0, path_1.join)(root, 'attachments/fk-upload', filename
|
81
|
-
task.filename = filename
|
81
|
+
const path = (0, path_1.join)(root, 'attachments/fk-upload', filename);
|
82
|
+
task.filename = filename;
|
82
83
|
task.url = url;
|
83
84
|
task.loginId = fkLoginId;
|
84
85
|
task.totalSize = 0;
|
@@ -159,6 +160,10 @@ let TaskService = class TaskService {
|
|
159
160
|
if (err)
|
160
161
|
return fail();
|
161
162
|
if (reply) {
|
163
|
+
const isExist = await this.db.manager.find(entities_1.FkDownloadTaskEntity, { where: { filename: task.filename } });
|
164
|
+
if (!isExist) {
|
165
|
+
return complete();
|
166
|
+
}
|
162
167
|
const taskIndex = Number(reply); // next
|
163
168
|
const isComplete = task.complete && task.index === taskIndex;
|
164
169
|
const isShouldRunning = isComplete || (!isComplete && task.index == taskIndex);
|
@@ -201,10 +206,9 @@ let TaskService = class TaskService {
|
|
201
206
|
this.redis.set(task.filename, `${task.index + 1}`);
|
202
207
|
if (data) {
|
203
208
|
// fullDownUrl
|
204
|
-
const downUrl = data.
|
209
|
+
const downUrl = data.path;
|
205
210
|
if (downUrl) {
|
206
211
|
const fullUrl = downUrl.startsWith('http') ? downUrl : `https:` + downUrl;
|
207
|
-
console.log({ data, task });
|
208
212
|
axios_1.default.post(`https://smr00.vip.webportal.top/ajax/advanceUpload.jsp?cmd=_report&_TOKEN=${task.token}`, this.encodeURIComponent({
|
209
213
|
type: 1,
|
210
214
|
size: task.total,
|