siyuan-note/siyuan · error
copy asset [ ] to [ ] failed
Error message
copy asset [%s] to [%s] failed: %w
What it means
createAssetsHistory copies each asset into the history snapshot with filelock.Copy. Missing source files are silently skipped (os.IsNotExist → continue), but any other copy failure is wrapped with source and destination paths plus the cause, aborting the snapshot. This means partially readable/locked files surface here rather than being silently dropped.
Solutions
- Inspect the wrapped cause plus the [%s] to [%s] paths in the message.
- Verify the source asset is readable and the history volume has free space and is writable.
- Re-run the snapshot after fixing; missing files are skipped by design, only real copy errors abort.
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check source readability for (const f of assets) fs.accessSync(f, fs.constants.R_OK);
Try / catch
try {
await createAssetHistory(p);
} catch (e) {
if (String(e).includes("copy asset")) {
// parse source/dest from message, check locks/space, retry once
}
} Prevention
- Ensure assets are not locked by other processes during snapshots.
- Keep free space headroom on the history volume.
- Treat NotNotExist as benign — the kernel skips missing sources by design.
When it happens
Trigger: filelock.Copy failing for a non-NotExist reason: permission denied reading the asset, I/O error on the destination volume, disk full mid-copy, or the source being a special/unreadable file.
Common situations: Assets locked by another process or antivirus; destination history volume out of space; permission mismatches after restoring data with wrong ownership; network-drive asset storage with transient I/O failures.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- accessing assets in encrypted notebook
- ambiguous asset path
- asset path must be a file
- check data.zip failed
- Conf.Language(0)
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/35c88afeb0ccd7c7.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/history.go:956
if err != nil {
return fmt.Errorf("get history directory failed: %w", err)
}
for _, file := range assets {
assetRelPath, relErr := filepath.Rel(filepath.Join(util.DataDir, "assets"), file)
if relErr != nil || assetRelPath == "." || strings.HasPrefix(assetRelPath, ".."+string(filepath.Separator)) {
return errors.New("asset path must be under assets")
}
historyPath := filepath.Join(historyDir, "assets", assetRelPath)
if err = os.MkdirAll(filepath.Dir(historyPath), 0755); err != nil {
return fmt.Errorf("create history directory [%s] failed: %w", filepath.Dir(historyPath), err)
}
if copyErr := filelock.Copy(file, historyPath); copyErr != nil {
if os.IsNotExist(copyErr) {
continue
}
return fmt.Errorf("copy asset [%s] to [%s] failed: %w", file, historyPath, copyErr)
}
}
indexHistoryDir(filepath.Base(historyDir), util.NewLute())
return
}
func (box *Box) generateDocHistory0() {
files := box.recentModifiedDocs()
if 1 > len(files) {
return
}
historyDir, err := getHistoryDir(HistoryOpUpdate)
if err != nil {
logging.LogErrorf("get history dir failed: %s", err)
return
}View on GitHub (pinned to 9f775e8a12)