{"record":{"id":"da33e4373bc471af","repo":"siyuan-note/siyuan","slug":"move-notebook-s-file-s-failed-s-da33e4","errorCode":null,"errorMessage":"Move notebook [%s] file [%s] failed: %s","messagePattern":"Move notebook \\[(.+?)\\] file \\[(.+?)\\] failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/file.go","lineNumber":1872,"sourceCode":"\tneedMoveSubDocs := fromBox.Exist(fromFolder)\n\tif needMoveSubDocs {\n\t\t// 移动子文档文件夹\n\n\t\tnewFolder := path.Join(toFolder, tree.ID)\n\t\tif isSameBox {\n\t\t\tif err = fromBox.Move(fromFolder, newFolder); err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tabsFromPath := filepath.Join(util.DataDir, fromBox.ID, fromFolder)\n\t\t\tabsToPath := filepath.Join(util.DataDir, toBox.ID, newFolder)\n\t\t\tif filelock.IsExist(absToPath) {\n\t\t\t\tfilelock.Remove(absToPath)\n\t\t\t}\n\t\t\tif err = filelock.Rename(absFromPath, absToPath); err != nil {\n\t\t\t\tmsg := fmt.Sprintf(Conf.Language(5), fromBox.Name, fromPath, err)\n\t\t\t\tlogging.LogErrorf(\"move [path=%s] in box [%s] failed: %s\", fromPath, fromBox.ID, err)\n\t\t\t\terr = errors.New(msg)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\tnewPath = path.Join(toFolder, tree.ID+\".sy\")\n\n\tif isSameBox {\n\t\tif err = fromBox.Move(fromPath, newPath); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\ttree, err = filesys.LoadTree(fromBox.ID, newPath, luteEngine)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tmoveTree(tree)","sourceCodeStart":1854,"sourceCodeEnd":1890,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/file.go#L1854-L1890","documentation":"Thrown by the internal moveDocsByPath function during a cross-box (isSameBox=false) move, when renaming the source document's sub-document folder (filelock.Rename) from the source notebook's data directory to the destination's fails. Conf.Language(5) = 'Move notebook [%s] file [%s] failed: %s', formatted with the source box name, source path, and the OS-level rename error. This is the sub-doc folder move (not the .sy file itself), occurring when the source document has child documents stored in a folder.","triggerScenarios":"Cross-notebook MoveDocs where the source document has sub-documents (fromFolder exists). The code at line 1864-1874 constructs absolute paths for both source and destination, removes any pre-existing destination, then calls filelock.Rename. Failure occurs on cross-device renames, permission errors, or if the source folder is locked by another process.","commonSituations":"Moving a document with many children between notebooks on different mount points (rename fails across filesystems). A file lock from antivirus or sync software on Windows blocks the source folder. The destination directory was removed by a concurrent operation between the IsExist check and the Rename call.","solutions":["Check kernel logs for the specific OS error appended to the message (the %s at the end of Language(5)).","If moving across filesystems, ensure both notebook data directories are on the same volume, or use copy-then-delete as a fallback.","Close other applications that may lock the source folder (sync clients, file explorers, antivirus).","Retry the move after a brief pause if the lock is transient.","If the destination already has conflicting data, manually clean it up before re-attempting."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := model.MoveDocs(fromPaths, toBoxID, toPath, callback); err != nil {\n    if strings.Contains(err.Error(), conf.Conf.Language(5)[:10]) {\n        // Move file failed — check logs for OS-level error\n        logging.LogErrorf(\"move failed, possible lock or cross-device: %s\", err)\n        // advise user to close locking apps or move within same volume\n    }\n    return err\n}","preventionTips":["Ensure source and destination notebooks are on the same filesystem to avoid cross-device rename failures.","Close sync clients, editors, and antivirus tools that may lock source folders before moving.","Check kernel logs for the specific OS error appended to the move-failed message.","For large moves, monitor disk space on both source and destination volumes."],"tags":["move","filesystem","cross-box","rename","filelock"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}