{"record":{"id":"24f6481fccef8aa5","repo":"siyuan-note/siyuan","slug":"global-attachment-s-already-exists","errorCode":null,"errorMessage":"global attachment [%s] already exists","messagePattern":"global attachment \\[(.+?)\\] already exists","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/model/import_obsidian.go","lineNumber":1778,"sourceCode":"\t\tmarkObsidianNotebookIncomplete(boxID, notebookName)\n\t\tfailObsidianTask(taskID, \"writing\", err, result)\n\t\tremoveObsidianTemp(taskID)\n\t\treturn\n\t}\n\tif err = os.MkdirAll(filepath.Join(util.DataDir, \"assets\"), 0755); err != nil {\n\t\tresult.Incomplete = true\n\t\tmarkObsidianNotebookIncomplete(boxID, notebookName)\n\t\tfailObsidianTask(taskID, \"writing\", err, result)\n\t\tremoveObsidianTemp(taskID)\n\t\treturn\n\t}\n\n\tfor _, key := range assetKeys {\n\t\tasset := vault.ImportAssets[key]\n\t\tsource := filepath.Join(assetsTemp, asset.FinalName)\n\t\tdestination := filepath.Join(util.DataDir, \"assets\", asset.FinalName)\n\t\tif filelock.IsExist(destination) {\n\t\t\terr = fmt.Errorf(\"global attachment [%s] already exists\", asset.FinalName)\n\t\t} else {\n\t\t\terr = filelock.Rename(source, destination)\n\t\t}\n\t\tif err != nil {\n\t\t\tresult.Incomplete = true\n\t\t\tmarkObsidianNotebookIncomplete(boxID, notebookName)\n\t\t\tfailObsidianTask(taskID, \"writing\", err, result)\n\t\t\tremoveObsidianTemp(taskID)\n\t\t\treturn\n\t\t}\n\t}\n\n\tupdateObsidianTask(taskID, ObsidianTaskStateIndexing, 95, \"Indexing notebook\")\n\texisted, err := Mount(boxID)\n\tif err != nil {\n\t\tresult.Incomplete = true\n\t\tmarkObsidianNotebookIncomplete(boxID, notebookName)\n\t\tfailObsidianTask(taskID, \"indexing\", err, result)","sourceCodeStart":1760,"sourceCodeEnd":1796,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/import_obsidian.go#L1760-L1796","documentation":"During the final move of staged attachments into the workspace's global assets folder (util.DataDir/assets), if a file with the target FinalName already exists there, the importer records err = \"global attachment [%s] already exists\" instead of overwriting. This marks the import result Incomplete and flags the notebook as incomplete, but does not abort the whole import.","triggerScenarios":"filelock.IsExist(destination) is true in the finalize loop — an attachment with the same final name already exists in data/assets/, typically from a previous import of the same or another vault.","commonSituations":"Re-importing a vault (or a second vault sharing image filenames like screenshot.png) into the same workspace; partially completed earlier import left the file behind.","solutions":["Check the existing file in data/assets/ with that name; if identical, remove the incomplete marker or accept the existing copy","If the existing file is unrelated/stale, delete or rename it in data/assets/ and re-run the import","Review the import result's Incomplete flag and the incomplete-notebook marker; re-import may be needed for a complete result"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before import, check for name collisions in the workspace assets dir\nfor _, name := range expectedFinalNames {\n    if _, err := os.Stat(filepath.Join(dataDir, \"assets\", name)); err == nil { /* collision: rename or remove */ }\n}","typeGuard":null,"tryCatchPattern":"if result.Incomplete {\n    // inspect which attachments conflicted; resolve collisions in data/assets/ and re-import\n}","preventionTips":["Avoid importing multiple vaults that reuse identical attachment filenames into one workspace","Clean up partial imports (leftover files in data/assets/) before re-importing","Rename colliding attachments in the source vault before import"],"tags":["go","obsidian-import","file-conflict"],"backgroundTag":"file-already-exists","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"}