@soga/uploader 0.2.29 → 0.2.31
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.
- package/dist/uploader.d.ts +0 -2
- package/dist/uploader.js +1 -1
- package/package.json +4 -4
package/dist/uploader.d.ts
CHANGED
|
@@ -16,8 +16,6 @@ export declare class Uploader {
|
|
|
16
16
|
start(): Promise<void>;
|
|
17
17
|
stopAll(): Promise<void>;
|
|
18
18
|
stopFiles(ids: number[]): Promise<void>;
|
|
19
|
-
repairAllParts(): Promise<void>;
|
|
20
|
-
repairParts(file_ids: number[]): Promise<void>;
|
|
21
19
|
private startHost;
|
|
22
20
|
private startAli;
|
|
23
21
|
private startBaidu;
|
package/dist/uploader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Uploader=void 0;const types_1=require("@soga/types"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Uploader=void 0;const types_1=require("@soga/types"),entities_1=require("@soga/entities"),baidu_1=require("./host-uploader/baidu"),ali_1=require("./host-uploader/ali"),complete_1=require("./hooks/complete"),trasform_1=require("./hooks/trasform");class Uploader{params;uid;dataSource;fileRepository;partRepository;constructor(s){this.params=s,this.uid=s.uid,this.dataSource=s.dataSource,this.fileRepository=this.dataSource.getRepository(entities_1.UploadFile),this.partRepository=this.dataSource.getRepository(entities_1.UploadPart)}processorMap=new Map;successing=!1;async onSuccess(s){for(;this.successing;)await new Promise((s=>setTimeout(s,100)));try{this.successing=!0,await(0,complete_1.complete)({file_id:s.id,fileRepository:this.fileRepository,sdk_domain:this.params.sdk_domain}),await(0,trasform_1.transform)({file_id:s.id,dataSource:this.dataSource}),console.log("onSuccess",s)}finally{this.successing=!1}}async init(){}async start(){await Promise.all([this.startAli(),this.startBaidu()])}async stopAll(){const s=this.processorMap.values();for(const t of s)await t.stopAll()}async stopFiles(s){const t=this.processorMap.values();for(const i of t)await i.stopFiles(s)}async startHost(s,t){if(this.processorMap.has(s)){const t=this.processorMap.get(s);return void await t.start()}const i={uid:this.uid,sdk_domain:this.params.sdk_domain,dataSource:this.dataSource,host_id:s,onProgress:this.params.onProgress,onSuccess:this.onSuccess.bind(this),onError:this.params.onError};if(t==types_1.HostType.BAIDU){const t=await(0,baidu_1.getBaiduUploader)(i);this.processorMap.set(s,t),await t.start()}else if(t==types_1.HostType.ALI){const t=await(0,ali_1.getAliUploader)(i);this.processorMap.set(s,t),await t.start()}}async startAli(){const s=(await this.fileRepository.createQueryBuilder("file").select("DISTINCT file.ali_host_id").where("file.uid = :uid",{uid:this.uid}).getRawMany()).map((s=>s.ali_host_id)).filter((s=>!!s));if(s.length)for(const t of s)await this.startHost(t,types_1.HostType.ALI)}async startBaidu(){const s=(await this.fileRepository.createQueryBuilder("file").select("DISTINCT file.baidu_host_id").where("file.uid = :uid",{uid:this.uid}).getRawMany()).map((s=>s.baidu_host_id)).filter((s=>!!s));if(s.length)for(const t of s)await this.startHost(t,types_1.HostType.BAIDU)}}exports.Uploader=Uploader;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soga/uploader",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.31",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"prepublishOnly": "npm run build"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@soga/encoder": "^0.2.
|
|
24
|
+
"@soga/encoder": "^0.2.31",
|
|
25
25
|
"@types/fs-extra": "^11.0.4",
|
|
26
26
|
"@types/glob": "^8.1.0",
|
|
27
27
|
"@types/jest": "^29.5.14",
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"typeorm": "*"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@soga/entities": "^0.2.
|
|
51
|
+
"@soga/entities": "^0.2.31",
|
|
52
52
|
"@soga/part-uploader": "^0.2.27",
|
|
53
53
|
"@soga/sdk": "^0.2.22",
|
|
54
54
|
"@soga/types": "^0.2.22",
|
|
55
55
|
"@soga/utils": "^0.2.22",
|
|
56
56
|
"piscina": "^4.9.2"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "52c8accbbc7637438cd3be69028653902c61f66e"
|
|
59
59
|
}
|