oicq-icalingua-plus-plus 1.26.28 → 1.26.29
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/index.d.ts +7 -1
- package/lib/message/qfile.js +15 -7
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -960,7 +960,13 @@ export interface FlashTransferMetadata {
|
|
|
960
960
|
file_count?: number;
|
|
961
961
|
}
|
|
962
962
|
|
|
963
|
-
export
|
|
963
|
+
export interface FlashTransferUploadDirectory {
|
|
964
|
+
name: string;
|
|
965
|
+
/** 虚拟目录的子项;文件仍从各自的源路径读取 */
|
|
966
|
+
children: FlashTransferUploadInput[];
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
export type FlashTransferUploadInput = MediaFile | { file: MediaFile; name?: string } | FlashTransferUploadDirectory;
|
|
964
970
|
|
|
965
971
|
export interface FlashTransferUploadSource {
|
|
966
972
|
name: string;
|
package/lib/message/qfile.js
CHANGED
|
@@ -251,7 +251,7 @@ class FlashTransfer {
|
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
/**
|
|
254
|
-
*
|
|
254
|
+
* 本地文件、目录、虚拟目录或 Buffer 的完整上传;直到文件同步和任务提交均成功才返回。
|
|
255
255
|
* @param {import("../../").FlashTransferUploadInput | import("../../").FlashTransferUploadInput[]} files
|
|
256
256
|
* @param {string} [name]
|
|
257
257
|
* @param {(percentage: string) => void} [callback]
|
|
@@ -274,7 +274,7 @@ class FlashTransfer {
|
|
|
274
274
|
let task;
|
|
275
275
|
let stage = "hash";
|
|
276
276
|
/**
|
|
277
|
-
* @param {import("../../").MediaFile} file
|
|
277
|
+
* @param {import("../../").MediaFile | import("../../").FlashTransferUploadDirectory} file
|
|
278
278
|
* @param {string} [file_name]
|
|
279
279
|
* @param {string} [parent_id]
|
|
280
280
|
* @param {number} [depth=1]
|
|
@@ -283,9 +283,15 @@ class FlashTransfer {
|
|
|
283
283
|
const collect = async (file, file_name, parent_id = "", depth = 1) => {
|
|
284
284
|
if (file_name !== undefined)
|
|
285
285
|
file_name = checkString(file_name, "file name");
|
|
286
|
+
const virtual = !!file && typeof file === "object" && "children" in file;
|
|
287
|
+
if (virtual) {
|
|
288
|
+
if (!Array.isArray(file.children))
|
|
289
|
+
throw new TypeError("directory children must be an array");
|
|
290
|
+
file_name = checkString(file_name || file.name, "directory name");
|
|
291
|
+
}
|
|
286
292
|
const binary = file instanceof Uint8Array || file instanceof ArrayBuffer || file instanceof SharedArrayBuffer;
|
|
287
293
|
let stat;
|
|
288
|
-
if (!binary) {
|
|
294
|
+
if (!virtual && !binary) {
|
|
289
295
|
if (typeof file !== "string")
|
|
290
296
|
throw new TypeError("upload source must be a local path or binary data");
|
|
291
297
|
file = path.resolve(file);
|
|
@@ -298,17 +304,19 @@ class FlashTransfer {
|
|
|
298
304
|
cli_fileid, parent_id, depth,
|
|
299
305
|
name: file_name || (!binary ? path.basename(file) : ""),
|
|
300
306
|
cli_file_index: metadata.length + 1,
|
|
301
|
-
is_dir: !!stat?.isDirectory(),
|
|
307
|
+
is_dir: virtual || !!stat?.isDirectory(),
|
|
302
308
|
file_size: 0,
|
|
303
309
|
file_count: 0,
|
|
304
310
|
};
|
|
305
311
|
metadata.push(meta);
|
|
306
312
|
if (meta.is_dir) {
|
|
307
313
|
meta.file_type = 25;
|
|
308
|
-
const children = await fs.promises.readdir(file, { withFileTypes: true })
|
|
309
|
-
|
|
314
|
+
const children = virtual ? file.children : (await fs.promises.readdir(file, { withFileTypes: true }))
|
|
315
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
316
|
+
.map(child => ({ file: path.join(file, child.name), name: child.name }));
|
|
310
317
|
for (const child of children) {
|
|
311
|
-
const
|
|
318
|
+
const input = child && typeof child === "object" && "file" in child ? child : { file: child };
|
|
319
|
+
const entry = await collect(input.file, input.name, cli_fileid, depth + 1);
|
|
312
320
|
meta.file_size += entry.file_size;
|
|
313
321
|
++meta.file_count;
|
|
314
322
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oicq-icalingua-plus-plus",
|
|
3
3
|
"app_name": "oicq-icalingua-plus-plus",
|
|
4
|
-
"version": "1.26.
|
|
5
|
-
"app_version": "1.26.
|
|
4
|
+
"version": "1.26.29",
|
|
5
|
+
"app_version": "1.26.29",
|
|
6
6
|
"upday": "2026/11/14",
|
|
7
7
|
"protocol_version": "v11",
|
|
8
8
|
"description": "oicq(https://github.com/takayama-lily/oicq) v1 for Icalingua++",
|