Skip to content

Commit a0c0bd5

Browse files
bingryanclaude
andcommitted
fix: resolve attachment export inconsistencies (#108)
- Unify filename encoding between tryCopyImage and tryCopyMarkdownByRead (both now use encodeURI(fileName) when fileNameEncode is off) - Add check to skip copying when source and target paths are identical (prevents file corruption for attachments already in output folder) Fixes issues where: - Some attachments had encoded names while others didn't - Attachment files were corrupted during export - Attachments were placed in different folders inconsistently 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e631e1a commit a0c0bd5

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/utils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ export async function tryCopyImage(
355355
const fileName = path.parse(path.basename(imageLink)).name;
356356
const imageLinkMd5 = plugin.settings.fileNameEncode
357357
? md5(imageLink)
358-
: fileName;
358+
: encodeURI(fileName);
359359
const imageExt = path.extname(imageLink);
360360
const ifile = plugin.app.metadataCache.getFirstLinkpathDest(
361361
imageLink,
@@ -394,6 +394,12 @@ export async function tryCopyImage(
394394
)
395395
.replace(/\\/g, "/");
396396

397+
// Skip if source and target are the same (prevents file corruption)
398+
// This can happen when an attachment is already in the output folder
399+
if (filePath === targetPath) {
400+
continue;
401+
}
402+
397403
try {
398404
if (!fileExists(targetPath)) {
399405
if (

0 commit comments

Comments
 (0)