baiduwangpan-cli 1.6.0 → 1.7.0
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/LICENSE +21 -21
- package/README.md +504 -471
- package/bin/bdp.js +1647 -1452
- package/lib/browser-login.js +427 -427
- package/lib/config.js +213 -213
- package/lib/console.js +99 -99
- package/lib/file-type.js +109 -0
- package/lib/group.js +929 -925
- package/lib/http.js +130 -130
- package/lib/index.js +7 -7
- package/lib/mcp.js +287 -0
- package/lib/name-match.js +67 -67
- package/lib/pan.js +1034 -767
- package/lib/partial.js +53 -53
- package/lib/pcs-extra.js +327 -318
- package/lib/table.js +173 -0
- package/package.json +48 -48
- package/scripts/postinstall.js +340 -340
package/lib/partial.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* lib/partial.js — gsearch --save-partial 的纯工具函数
|
|
3
|
-
*
|
|
4
|
-
* 用途:搜索未完整(超时/限流/预算耗尽/失败)时,自动把已搜到的部分结果
|
|
5
|
-
* 落盘到 JSON 文件,避免"跑完了才发现只有 partial:true、结果却没保存"。
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const path = require("path");
|
|
9
|
-
|
|
10
|
-
// 非法文件名字符(Windows/Linux 通用)
|
|
11
|
-
const ILLEGAL = /[\\/:*?"<>|]/g;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* --save-partial 未指定 --json-file 时的默认保存路径:
|
|
15
|
-
* <cwd>/bdp-gsearch-<gid>-<keyword>-partial-<timestamp>.json
|
|
16
|
-
*/
|
|
17
|
-
function defaultPartialFile(gid, keyword, options = {}) {
|
|
18
|
-
const cwd = options.cwd || process.cwd();
|
|
19
|
-
const date = options.date || new Date();
|
|
20
|
-
const safeKw = String(keyword == null ? "" : keyword).replace(ILLEGAL, "_").slice(0, 40) || "search";
|
|
21
|
-
const ts = date.toISOString().replace(/[:.]/g, "-");
|
|
22
|
-
return path.join(cwd, `bdp-gsearch-${String(gid)}-${safeKw}-partial-${ts}.json`);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 部分结果落盘对象:results 为已搜到的全部匹配(不翻页切片),
|
|
27
|
-
* 附带扫描诊断(scannedShares/totalShares/failedShares/stoppedReason 等),
|
|
28
|
-
* 供 Agent / 用户超时后直接读取。
|
|
29
|
-
*/
|
|
30
|
-
function buildPartialPayload(result, meta = {}) {
|
|
31
|
-
return {
|
|
32
|
-
saved: "partial",
|
|
33
|
-
partial: true,
|
|
34
|
-
complete: false,
|
|
35
|
-
timedOut: !!result.timedOut,
|
|
36
|
-
stoppedReason: result.stoppedReason || null,
|
|
37
|
-
gid: meta.gid,
|
|
38
|
-
keyword: meta.keyword,
|
|
39
|
-
page: result.page,
|
|
40
|
-
pageSize: result.pageSize,
|
|
41
|
-
total: result.results.length,
|
|
42
|
-
results: result.results,
|
|
43
|
-
scannedShares: result.scannedShares,
|
|
44
|
-
totalShares: result.totalShares,
|
|
45
|
-
failedShares: result.failedShares,
|
|
46
|
-
throttledShares: result.throttledShares,
|
|
47
|
-
cachedDirs: result.cachedDirs,
|
|
48
|
-
budgetUsed: result.budgetUsed,
|
|
49
|
-
depth: result.depth,
|
|
50
|
-
maxPages: result.maxPages,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
1
|
+
/**
|
|
2
|
+
* lib/partial.js — gsearch --save-partial 的纯工具函数
|
|
3
|
+
*
|
|
4
|
+
* 用途:搜索未完整(超时/限流/预算耗尽/失败)时,自动把已搜到的部分结果
|
|
5
|
+
* 落盘到 JSON 文件,避免"跑完了才发现只有 partial:true、结果却没保存"。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const path = require("path");
|
|
9
|
+
|
|
10
|
+
// 非法文件名字符(Windows/Linux 通用)
|
|
11
|
+
const ILLEGAL = /[\\/:*?"<>|]/g;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* --save-partial 未指定 --json-file 时的默认保存路径:
|
|
15
|
+
* <cwd>/bdp-gsearch-<gid>-<keyword>-partial-<timestamp>.json
|
|
16
|
+
*/
|
|
17
|
+
function defaultPartialFile(gid, keyword, options = {}) {
|
|
18
|
+
const cwd = options.cwd || process.cwd();
|
|
19
|
+
const date = options.date || new Date();
|
|
20
|
+
const safeKw = String(keyword == null ? "" : keyword).replace(ILLEGAL, "_").slice(0, 40) || "search";
|
|
21
|
+
const ts = date.toISOString().replace(/[:.]/g, "-");
|
|
22
|
+
return path.join(cwd, `bdp-gsearch-${String(gid)}-${safeKw}-partial-${ts}.json`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 部分结果落盘对象:results 为已搜到的全部匹配(不翻页切片),
|
|
27
|
+
* 附带扫描诊断(scannedShares/totalShares/failedShares/stoppedReason 等),
|
|
28
|
+
* 供 Agent / 用户超时后直接读取。
|
|
29
|
+
*/
|
|
30
|
+
function buildPartialPayload(result, meta = {}) {
|
|
31
|
+
return {
|
|
32
|
+
saved: "partial",
|
|
33
|
+
partial: true,
|
|
34
|
+
complete: false,
|
|
35
|
+
timedOut: !!result.timedOut,
|
|
36
|
+
stoppedReason: result.stoppedReason || null,
|
|
37
|
+
gid: meta.gid,
|
|
38
|
+
keyword: meta.keyword,
|
|
39
|
+
page: result.page,
|
|
40
|
+
pageSize: result.pageSize,
|
|
41
|
+
total: result.results.length,
|
|
42
|
+
results: result.results,
|
|
43
|
+
scannedShares: result.scannedShares,
|
|
44
|
+
totalShares: result.totalShares,
|
|
45
|
+
failedShares: result.failedShares,
|
|
46
|
+
throttledShares: result.throttledShares,
|
|
47
|
+
cachedDirs: result.cachedDirs,
|
|
48
|
+
budgetUsed: result.budgetUsed,
|
|
49
|
+
depth: result.depth,
|
|
50
|
+
maxPages: result.maxPages,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
54
|
module.exports = { defaultPartialFile, buildPartialPayload };
|