Add isLocal flag to uriToLocalFile and use it
Expose an isLocal boolean from uriToLocalFile to indicate user-owned files vs temporary downloads/decodes, and update callers to avoid deleting or cleaning up user local files. Update OneBot file APIs to accept the isLocal hint (including createValidSendFileElement/createValidSendPicElement/createValidSendVideoElement) and adjust temp-file handling for videos: local files are copied into the NapCat temp dir with a random UUID filename to avoid polluting user directories, while temporary files get an added extension in-place. Also adjust deleteAfterSentFiles usage, image/video thumb handling, and numeric parsing fallbacks for element fileSize to be more robust. Minor imports (randomUUID) and related callsites were updated accordingly.
This commit is contained in:
1 parent
7a974d38d4
commit
07d4d80ab7
11 files changed
+76
-44
No files matched your search
@@ -40,6 +40,7 @@ export class SendGroupNotice extends OneBotAction<SendGroupNoticePayload, void>
|
||||
const {
|
||||
path,
|
||||
success,
|
||||
isLocal,
|
||||
} = (await uriToLocalFile(this.core.NapCatTempPath, payload.image));
|
||||
if (!success) {
|
||||
throw new Error(`群公告${payload.image}设置失败,image字段可能格式不正确`);
|
||||
@@ -53,7 +54,7 @@ export class SendGroupNotice extends OneBotAction<SendGroupNoticePayload, void>
|
||||
throw new Error(`群公告${payload.image}设置失败,图片上传失败 , 错误信息:${ImageUploadResult.errMsg}`);
|
||||
}
|
||||
|
||||
unlink(path).catch(() => { });
|
||||
if (!isLocal) unlink(path).catch(() => { });
|
||||
|
||||
UploadImage = ImageUploadResult.picInfo;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user