@freelog/tools-lib 0.1.113 → 0.1.114

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.
@@ -1,66 +1,69 @@
1
- import * as Tool from '../../utils/tools';
2
- import * as Storage from '../storages';
3
-
4
- interface FileInfo {
5
- sha1: string;
6
- state: 'success' | 'fail' | 'nonentity';
7
- info: {
8
- [key: string]: any;
9
- }
10
- }
11
-
12
- interface GetFileInfosBySha1Params {
13
- sha1: string[];
14
- }
15
-
16
- export async function getFilesSha1Info({sha1}: GetFileInfosBySha1Params, cdPartially: (s: any[]) => void = () => undefined): Promise<FileInfo[]> {
17
- if (sha1.length === 0) {
18
- return [];
19
- }
20
-
21
- let needHandleSha1: string[] = [...sha1];
22
-
23
- let allData: FileInfo[] = [];
24
-
25
- while (true) {
26
- console.log(needHandleSha1.join(','), 'needHandleSha1.join()90ojlskdfjsdlk')
27
- const {data} = await Storage.filesListInfo({
28
- sha1: needHandleSha1.join(','),
29
- });
30
- needHandleSha1 = data
31
- .filter((d: any) => {
32
- return d.metaAnalyzeStatus && d.metaAnalyzeStatus === 1;
33
- })
34
- .map((d: any) => {
35
- return d.sha1;
36
- });
37
- const finishedInfo: FileInfo[] = data
38
- .filter((d: any) => {
39
- return !d.metaAnalyzeStatus || d.metaAnalyzeStatus !== 1;
40
- })
41
- .map((d: any) => {
42
- let state: 'success' | 'fail' | 'nonentity' = 'fail';
43
- if (!d.metaAnalyzeStatus) {
44
- state = 'nonentity';
45
- } else if (d.metaAnalyzeStatus === 2) {
46
- state = 'success';
47
- }
48
- return {
49
- sha1: d.sha1,
50
- state,
51
- info: d,
52
- };
53
- });
54
- cdPartially && cdPartially(finishedInfo);
55
- allData = [
56
- ...allData,
57
- ...finishedInfo,
58
- ];
59
-
60
- if (needHandleSha1.length === 0) {
61
- break;
62
- }
63
- await Tool.promiseSleep(3000)
64
- }
65
- return allData;
66
- }
1
+ import * as Tool from '../../utils/tools';
2
+ import * as Storage from '../storages';
3
+
4
+ interface FileInfo {
5
+ sha1: string;
6
+ state: 'success' | 'fail' | 'nonentity';
7
+ info: {
8
+ [key: string]: any;
9
+ }
10
+ }
11
+
12
+ interface GetFileInfosBySha1Params {
13
+ sha1: string[];
14
+ }
15
+
16
+ export async function getFilesSha1Info({sha1}: GetFileInfosBySha1Params, cdPartially: (s: any[]) => void = () => undefined): Promise<FileInfo[]> {
17
+ if (sha1.length === 0) {
18
+ return [];
19
+ }
20
+
21
+ let delay: number = 500;
22
+
23
+ let needHandleSha1: string[] = [...sha1];
24
+
25
+ let allData: FileInfo[] = [];
26
+
27
+ while (true) {
28
+ // console.log(needHandleSha1.join(','), 'needHandleSha1.join()90ojlskdfjsdlk')
29
+ const {data} = await Storage.filesListInfo({
30
+ sha1: needHandleSha1.join(','),
31
+ });
32
+ needHandleSha1 = data
33
+ .filter((d: any) => {
34
+ return d.metaAnalyzeStatus && d.metaAnalyzeStatus === 1;
35
+ })
36
+ .map((d: any) => {
37
+ return d.sha1;
38
+ });
39
+ const finishedInfo: FileInfo[] = data
40
+ .filter((d: any) => {
41
+ return !d.metaAnalyzeStatus || d.metaAnalyzeStatus !== 1;
42
+ })
43
+ .map((d: any) => {
44
+ let state: 'success' | 'fail' | 'nonentity' = 'fail';
45
+ if (!d.metaAnalyzeStatus) {
46
+ state = 'nonentity';
47
+ } else if (d.metaAnalyzeStatus === 2) {
48
+ state = 'success';
49
+ }
50
+ return {
51
+ sha1: d.sha1,
52
+ state,
53
+ info: d,
54
+ };
55
+ });
56
+ cdPartially && cdPartially(finishedInfo);
57
+ allData = [
58
+ ...allData,
59
+ ...finishedInfo,
60
+ ];
61
+
62
+ if (needHandleSha1.length === 0) {
63
+ break;
64
+ }
65
+ await Tool.promiseSleep(delay);
66
+ // delay += 500;
67
+ }
68
+ return allData;
69
+ }
@@ -87,6 +87,7 @@ interface ListParamsType {
87
87
  isLoadLatestVersionInfo?: 0 | 1;
88
88
  projection?: string;
89
89
  sort?: string;
90
+ userId?: number;
90
91
  }
91
92
 
92
93
  interface ListReturnType extends CommonReturn {