siyuan-note/siyuan · error
refuse to overwrite existing encrypted notebook
Error message
refuse to overwrite existing encrypted notebook [%s]
What it means
During data.zip import, if a notebook ID in the archive matches an existing encrypted notebook already present in the target workspace, the import refuses to overwrite it. Overwriting would destroy existing encrypted data whose identity may differ from the imported one, making recovery impossible.
Solutions
- Rename or move the existing encrypted notebook out of the workspace (or change its ID) before importing
- Delete the existing encrypted notebook intentionally if it is no longer needed, then re-run the import
- Import into a fresh/empty workspace directory when the goal is a full restore
- If both copies are needed, re-export one of them after giving it a different notebook ID
Defensive patterns
Strategy: validation
Validate before calling
// Go: check for ID collisions with existing encrypted notebooks before import
for _, boxID := range zipNotebookIDs(zipPath) {
if filelock.IsExist(filepath.Join(util.DataDir, boxID)) && model.IsEncryptedBox(boxID) {
return fmt.Errorf("archive notebook %s collides with an existing encrypted notebook; rename or remove it first", boxID)
}
} Prevention
- Restore data.zip backups into a clean workspace, not one that already contains the same notebooks
- Rename/re-ID notebooks before re-exporting when both copies must coexist
- Keep an inventory of notebook IDs used across backup archives
- Never rely on import to merge over existing encrypted data
When it happens
Trigger: ImportData with a data.zip containing a notebook whose ID equals an existing encrypted notebook ID in util.DataDir and IsEncryptedBox(boxID) is true for the existing notebook.
Common situations: Re-importing the same workspace backup twice; importing an old backup over a workspace where the same notebook was later re-created and encrypted with a different master key; restoring data.zip into a workspace that already synced that notebook.
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
- notebook [ ] has conflicting normal and encrypted identities
- Conf.Language(388) with escaped relative path…
- encrypted notebook [ ] has no valid identity
- imported notebook [ ] contains encrypted payload without…
- invalid imported notebook identity
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/16c0d0ca682721dd.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/import.go:1383
boxCrypt = backup
}
payloadFound, payloadErr := hasEncryptedNotebookPayloadAtPath(boxDir)
if payloadErr != nil {
return nil, fmt.Errorf("inspect imported notebook [%s] failed: %w", boxID, payloadErr)
}
if boxCrypt == nil && payloadFound {
return nil, fmt.Errorf("imported notebook [%s] contains encrypted payload without identity", boxID)
}
if boxCrypt == nil {
continue
}
if err = validateBoxEncryption(boxCrypt); err != nil {
return nil, fmt.Errorf("invalid imported notebook identity [%s]: %w", boxID, err)
}
if filelock.IsExist(filepath.Join(util.DataDir, boxID)) && IsEncryptedBox(boxID) {
return nil, fmt.Errorf("refuse to overwrite existing encrypted notebook [%s]", boxID)
}
encryptedBoxIDs = append(encryptedBoxIDs, boxID)
}
return encryptedBoxIDs, nil
}
func ImportData(zipPath string) (err error) {
util.PushEndlessProgress(Conf.Language(73))
defer util.ClearPushProgress(100)
lockSync()
defer unlockSync()
logging.LogInfof("import data from [%s]", zipPath)
baseName := filepath.Base(zipPath)
ext := filepath.Ext(baseName)
baseName = strings.TrimSuffix(baseName, ext)
unzipPath := filepath.Join(filepath.Dir(zipPath), baseName)View on GitHub (pinned to 9f775e8a12)