fix(flash-transfer): honor create_flash_task name as the card title
create_flash_task already accepted `name`, but the flash card still showed the first filename. Use a non-empty name as the fileset title and keep the real filenames on the files themselves. Fixes #363
This commit is contained in:
2 files changed
+53
-5
No files matched your search
@@ -413,14 +413,15 @@ export class FlashTransferApi {
|
||||
* 多文件:0x93d0 的 f4 是 repeated,一个 commit 请求同时携带 fileset 内所有文件
|
||||
* 条目,每条 f6=文件序号(1,2,3...)。commit 在上传前只发一次,之后 complete →
|
||||
* 逐个 prepare/apply/sliceupload。prepare/apply 的 filesetWrap.f4 必须与 commit
|
||||
* 的 f6 一致,否则文件不计入 fileset。多文件时 ApplyFileset 的 fileName 用
|
||||
* 「<首文件名>等N个文件」、fileSize 用总和——服务端据此判定 fileset 为多文件。
|
||||
* 的 f6 一致,否则文件不计入 fileset。ApplyFileset 的 fileName 是 fileset 显示名
|
||||
* (卡片标题):有 name 用 name,否则单文件用首文件名、多文件用「<首文件名>等N个文件」。
|
||||
* fileSize 用总和——服务端据此判定 fileset 为多文件。各文件在 commit 里仍用真实文件名。
|
||||
*
|
||||
* 源文件经 stageSourceToDisk 落到本地路径后流式哈希 / 分片读取,不再经
|
||||
* loadBinarySource 整文件进内存。本地与 HTTP 上限与群文件相同(4 GiB);
|
||||
* 内联 base64 仍按 1 GiB 封顶,因为 stage 解码时会占用等量 RAM。
|
||||
*/
|
||||
async createFlashTask(files: string | string[], _name?: string, _thumbPath?: string): Promise<{ filesetId: string }> {
|
||||
async createFlashTask(files: string | string[], name?: string, _thumbPath?: string): Promise<{ filesetId: string }> {
|
||||
const fileList = Array.isArray(files) ? files : [files];
|
||||
if (fileList.length === 0) throw new Error('create_flash_task: files is empty');
|
||||
const uploader = {
|
||||
@@ -449,12 +450,14 @@ export class FlashTransferApi {
|
||||
});
|
||||
if (staged.fileSize === 0) throw new Error('create_flash_task: file is empty');
|
||||
}
|
||||
// 申请 fileset。多文件时 fileName 用「<首文件名>等N个文件」、fileSize 用总和,
|
||||
// 申请 fileset。fileName 是卡片/面板上的 fileset 标题;各文件真实名走 commit。
|
||||
// 未指定 name 时,多文件用「<首文件名>等N个文件」、fileSize 用总和,
|
||||
// 服务端据此判定 fileset 为多文件,commit 的后续 entry 才会被计入。
|
||||
const first = items[0];
|
||||
const { typeCode } = FlashTransferApi.fileTypeCode(first.fileName);
|
||||
const isMulti = items.length > 1;
|
||||
const filesetName = isMulti ? `${first.fileName}等${items.length}个文件` : first.fileName;
|
||||
const filesetName = name?.trim()
|
||||
|| (isMulti ? `${first.fileName}等${items.length}个文件` : first.fileName);
|
||||
const totalSize = items.reduce((s, it) => s + it.fileSize, 0);
|
||||
const apply = await ApplyFileset.invoke(this.ctx, {
|
||||
fileName: filesetName, origName: filesetName,
|
||||
|
||||
Reference in new issue
Block a user