@nger/fk-upload 1.0.25 → 1.0.28

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,14 +70,14 @@ 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
- const filename = cid.toString('base64');
73
+ const filename = encodeURIComponent(cid.toString('base64'));
74
74
  const _url = new URL(url);
75
75
  const filePath = _url.pathname;
76
76
  const ext = (0, path_1.extname)(filePath);
77
77
  const task = new entities_1.FkDownloadTaskEntity();
78
78
  const root = this.injector.get(core_1.APP_ROOT);
79
79
  (0, fs_extra_1.ensureDirSync)((0, path_1.join)(root, 'attachments/fk-upload'));
80
- const path = (0, path_1.join)(root, 'attachments/fk-upload', encodeURIComponent(filename));
80
+ const path = (0, path_1.join)(root, 'attachments/fk-upload', filename + ext);
81
81
  task.filename = filename + ext;
82
82
  task.url = url;
83
83
  task.loginId = fkLoginId;
@@ -159,6 +159,10 @@ let TaskService = class TaskService {
159
159
  if (err)
160
160
  return fail();
161
161
  if (reply) {
162
+ const isExist = await this.db.manager.find(entities_1.FkDownloadTaskEntity, { where: { filename: task.filename } });
163
+ if (!isExist) {
164
+ return complete();
165
+ }
162
166
  const taskIndex = Number(reply); // next
163
167
  const isComplete = task.complete && task.index === taskIndex;
164
168
  const isShouldRunning = isComplete || (!isComplete && task.index == taskIndex);
@@ -167,16 +171,16 @@ let TaskService = class TaskService {
167
171
  const fileStream = (0, fs_extra_1.createReadStream)(task.path, { start: task.start, end: task.end });
168
172
  const formdata = new form_data_1.default();
169
173
  formdata.append('ctrl', fileStream);
170
- formdata.append('isFreeVer', 'false');
171
- formdata.append('aid', `${task.aid}`);
172
- formdata.append('folderId', `${task.folderId}`);
174
+ formdata.append('isFreeVer', this.encodeURIComponent(false));
175
+ formdata.append('aid', this.encodeURIComponent(task.aid));
176
+ formdata.append('folderId', this.encodeURIComponent(task.folderId));
173
177
  formdata.append('fileName', task.filename);
174
- formdata.append(`totalSize`, `${task.total}`);
178
+ formdata.append(`totalSize`, this.encodeURIComponent(task.total));
175
179
  formdata.append(`fileMd5`, task.fileMd5);
176
- formdata.append('index', `${task.index}`);
177
- formdata.append('chunkSize', `${task.splitSize}`);
178
- formdata.append('totalChunks', `${task.totalChunks}`);
179
- formdata.append(`complete`, `${task.complete}`);
180
+ formdata.append('index', this.encodeURIComponent(task.index));
181
+ formdata.append('chunkSize', this.encodeURIComponent(task.splitSize));
182
+ formdata.append('totalChunks', this.encodeURIComponent(task.totalChunks));
183
+ formdata.append(`complete`, this.encodeURIComponent(task.complete));
180
184
  const bssInfo = {
181
185
  fromSite: true, siteId: 0, groupId: 0, fileSizeLimit: 1024
182
186
  };
@@ -310,6 +314,9 @@ let TaskService = class TaskService {
310
314
  return `https://${token.url}/${token.visitType}/${token.app}/advance/info?cmd=${token.cmd}&token=${token.token}`;
311
315
  }
312
316
  encodeURIComponent(data) {
317
+ if ((0, core_1.isPrimitive)(data)) {
318
+ return encodeURIComponent(data);
319
+ }
313
320
  return Object.keys(data).map(key => {
314
321
  const value = Reflect.get(data, key);
315
322
  return `${key}=${encodeURIComponent(value)}`;
@@ -343,7 +350,7 @@ let TaskService = class TaskService {
343
350
  }
344
351
  if (token.length > 0) {
345
352
  // 01
346
- const url = `https://smr00.vip.webportal.top/cn/api/manage/advanceUpload/genAccessKey?_v=1651232099799&_TOKEN=${token}`;
353
+ const url = `https://smr00.vip.webportal.top/cn/api/manage/advanceUpload/genAccessKey?_v=${new Date().getTime()}&_TOKEN=${token}`;
347
354
  const accessKey = await axios_1.default.get(url).then(res => res.data);
348
355
  if (accessKey.success) {
349
356
  const accessTokenString = decode(accessKey.accessKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nger/fk-upload",
3
- "version": "1.0.25",
3
+ "version": "1.0.28",
4
4
  "description": "",
5
5
  "main": "dist/core.js",
6
6
  "types": "dist/core.d.ts",