{"record":{"id":"8ac0d980571ab3bc","repo":"siyuan-note/siyuan","slug":"path-size-or-modification-time-differs","errorCode":null,"errorMessage":"path, size or modification time differs","messagePattern":"path, size or modification time differs","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/import_obsidian.go","lineNumber":1888,"sourceCode":"\tfor _, asset := range vault.ImportAssets {\n\t\tif err := ctx.Err(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := validateObsidianSourceMetadata(asset.Source); err != nil {\n\t\t\treturn newObsidianUserError(346, asset.Source.RelPath,\n\t\t\t\tfmt.Errorf(\"attachment [%s] changed after analysis: %w\", asset.Source.RelPath, err))\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc validateObsidianSourceMetadata(file *obsidianSourceFile) error {\n\tinfo, err := os.Stat(file.AbsPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif info.Size() != file.Size || !info.ModTime().Equal(file.ModTime) {\n\t\treturn errors.New(\"path, size or modification time differs\")\n\t}\n\treturn nil\n}\n\nfunc transformObsidianMarkdown(vault *obsidianVaultContext, doc *obsidianDocPlan, data []byte) ([]byte, *obsidianTransformStats) {\n\tscan := scanObsidianSource(data)\n\tstats := &obsidianTransformStats{ReservedIDs: map[string]bool{}, FootnoteIDs: map[string]bool{}, PreservedComments: len(scan.Comments)}\n\tfor _, heading := range doc.Headings {\n\t\tstats.ReservedIDs[heading.ID] = true\n\t}\n\tfor _, id := range doc.BlockIDs {\n\t\tstats.ReservedIDs[id] = true\n\t}\n\n\ttype replacement struct {\n\t\tstart int\n\t\tend   int\n\t\ttext  string","sourceCodeStart":1870,"sourceCodeEnd":1906,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/import_obsidian.go#L1870-L1906","documentation":"validateObsidianSourceMetadata stats the source file and compares its size and modification time against the values captured during import analysis. Any mismatch means the file on disk is not the one that was analyzed, so validation fails with 'path, size or modification time differs'.","triggerScenarios":"Calling `validateObsidianSourceMetadata(file)` where `os.Stat(file.AbsPath)` succeeds but `info.Size() != file.Size` or `!info.ModTime().Equal(file.ModTime)`.","commonSituations":"The Obsidian attachment was re-saved (touch/mtime change with same content), synced/rewritten by cloud storage, or replaced by a different file with the same name between analysis and import.","solutions":["Re-run the import analysis so recorded Size/ModTime match the current file","Restore the file to its analyzed state (revert edits, re-download from sync)","If only mtime changed but content is identical, re-copy the file or update the captured metadata before validating"],"exampleFix":"// before: stale recorded metadata\nif info.Size() != file.Size || !info.ModTime().Equal(file.ModTime) {\n    return errors.New(\"path, size or modification time differs\")\n}\n// after: refresh recorded metadata when content is unchanged (same content hash)\nif info.Size() != file.Size || !info.ModTime().Equal(file.ModTime) {\n    if sameHash(file.AbsPath, file.ContentHash) {\n        file.Size, file.ModTime = info.Size(), info.ModTime()\n    } else {\n        return errors.New(\"path, size or modification time differs\")\n    }\n}","handlingStrategy":"validation","validationCode":"info, err := os.Stat(file.AbsPath)\nif err != nil {\n    return err\n}\nif info.Size() != file.Size || !info.ModTime().Equal(file.ModTime) {\n    return errors.New(\"file changed since analysis; re-run import\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Close editors holding the attachment open before importing","Disable mtime-updating sync tools during import","Re-analyze the vault if any file was touched"],"tags":["file","obsidian-import","mtime-mismatch"],"backgroundTag":"checksum-mismatch","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}