siyuan-note/siyuan · warning
global attachment [ ] already exists
Error message
global attachment [%s] already exists
What it means
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.
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
Defensive patterns
Strategy: validation
Validate before calling
// before import, check for name collisions in the workspace assets dir
for _, name := range expectedFinalNames {
if _, err := os.Stat(filepath.Join(dataDir, "assets", name)); err == nil { /* collision: rename or remove */ }
} Try / catch
if result.Incomplete {
// inspect which attachments conflicted; resolve collisions in data/assets/ and re-import
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/24f6481fccef8aa5.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/import_obsidian.go:1778
markObsidianNotebookIncomplete(boxID, notebookName)
failObsidianTask(taskID, "writing", err, result)
removeObsidianTemp(taskID)
return
}
if err = os.MkdirAll(filepath.Join(util.DataDir, "assets"), 0755); err != nil {
result.Incomplete = true
markObsidianNotebookIncomplete(boxID, notebookName)
failObsidianTask(taskID, "writing", err, result)
removeObsidianTemp(taskID)
return
}
for _, key := range assetKeys {
asset := vault.ImportAssets[key]
source := filepath.Join(assetsTemp, asset.FinalName)
destination := filepath.Join(util.DataDir, "assets", asset.FinalName)
if filelock.IsExist(destination) {
err = fmt.Errorf("global attachment [%s] already exists", asset.FinalName)
} else {
err = filelock.Rename(source, destination)
}
if err != nil {
result.Incomplete = true
markObsidianNotebookIncomplete(boxID, notebookName)
failObsidianTask(taskID, "writing", err, result)
removeObsidianTemp(taskID)
return
}
}
updateObsidianTask(taskID, ObsidianTaskStateIndexing, 95, "Indexing notebook")
existed, err := Mount(boxID)
if err != nil {
result.Incomplete = true
markObsidianNotebookIncomplete(boxID, notebookName)
failObsidianTask(taskID, "indexing", err, result)View on GitHub (pinned to 9f775e8a12)