{"record":{"id":"35c88afeb0ccd7c7","repo":"siyuan-note/siyuan","slug":"copy-asset-s-to-s-failed-w","errorCode":null,"errorMessage":"copy asset [%s] to [%s] failed: %w","messagePattern":"copy asset \\[(.+?)\\] to \\[(.+?)\\] failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/history.go","lineNumber":956,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"get history directory failed: %w\", err)\n\t}\n\n\tfor _, file := range assets {\n\t\tassetRelPath, relErr := filepath.Rel(filepath.Join(util.DataDir, \"assets\"), file)\n\t\tif relErr != nil || assetRelPath == \".\" || strings.HasPrefix(assetRelPath, \"..\"+string(filepath.Separator)) {\n\t\t\treturn errors.New(\"asset path must be under assets\")\n\t\t}\n\t\thistoryPath := filepath.Join(historyDir, \"assets\", assetRelPath)\n\t\tif err = os.MkdirAll(filepath.Dir(historyPath), 0755); err != nil {\n\t\t\treturn fmt.Errorf(\"create history directory [%s] failed: %w\", filepath.Dir(historyPath), err)\n\t\t}\n\n\t\tif copyErr := filelock.Copy(file, historyPath); copyErr != nil {\n\t\t\tif os.IsNotExist(copyErr) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"copy asset [%s] to [%s] failed: %w\", file, historyPath, copyErr)\n\t\t}\n\t}\n\n\tindexHistoryDir(filepath.Base(historyDir), util.NewLute())\n\treturn\n}\n\nfunc (box *Box) generateDocHistory0() {\n\tfiles := box.recentModifiedDocs()\n\tif 1 > len(files) {\n\t\treturn\n\t}\n\n\thistoryDir, err := getHistoryDir(HistoryOpUpdate)\n\tif err != nil {\n\t\tlogging.LogErrorf(\"get history dir failed: %s\", err)\n\t\treturn\n\t}","sourceCodeStart":938,"sourceCodeEnd":974,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/history.go#L938-L974","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-check source readability\nfor (const f of assets) fs.accessSync(f, fs.constants.R_OK);","typeGuard":null,"tryCatchPattern":"try {\n  await createAssetHistory(p);\n} catch (e) {\n  if (String(e).includes(\"copy asset\")) {\n    // parse source/dest from message, check locks/space, retry once\n  }\n}","preventionTips":["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."],"tags":["filesystem","io","copy","assets"],"backgroundTag":"file-write-failed","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"}