{"record":{"id":"2aa62b7fa5f77db2","repo":"siyuan-note/siyuan","slug":"conf-language-14-copy-resource-failed-s","errorCode":null,"errorMessage":"Conf.Language(14) (copy resource failed: %s)","messagePattern":"Conf\\.Language\\(14\\) \\(copy resource failed: (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/export.go","lineNumber":886,"sourceCode":"\t\t\tos.Remove(zipFilePath)\n\t\t\tos.Remove(zipFilePath + \".partial\")\n\t\t}\n\t}()\n\n\t// 将需要导出的文件/文件夹复制到临时文件夹\n\tfor _, resourcePath := range resourcePaths {\n\t\tresourceFullPath := filepath.Join(util.WorkspaceDir, resourcePath) // 资源完整路径\n\t\tif !util.IsAbsPathInWorkspace(resourceFullPath) {\n\t\t\tlogging.LogErrorf(\"resource path [%s] is not in workspace\", resourceFullPath)\n\t\t\terr = errors.New(\"resource path [\" + resourcePath + \"] is not in workspace\")\n\t\t\treturn\n\t\t}\n\n\t\tresourceBaseName := filepath.Base(resourceFullPath)                   // 资源名称\n\t\tresourceCopyPath := filepath.Join(exportFolderPath, resourceBaseName) // 资源副本完整路径\n\t\tif err = copyExportResource(resourceFullPath, resourceCopyPath); err != nil {\n\t\t\tlogging.LogErrorf(\"copy resource will be exported from [%s] to [%s] failed: %s\", resourcePath, resourceCopyPath, err)\n\t\t\terr = fmt.Errorf(Conf.Language(14), err.Error())\n\t\t\treturn\n\t\t}\n\t}\n\n\tzipPartialPath := zipFilePath + \".partial\"\n\tzip, err := gulu.Zip.Create(zipPartialPath)\n\tif err != nil {\n\t\tlogging.LogErrorf(\"create export zip [%s] failed: %s\", zipFilePath, err)\n\t\treturn\n\t}\n\tzipClosed := false\n\tdefer func() {\n\t\tif !zipClosed {\n\t\t\t_ = zip.Close()\n\t\t}\n\t}()\n\n\tif err = zip.AddDirectory(zipBaseName, exportFolderPath); err != nil {","sourceCodeStart":868,"sourceCodeEnd":904,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/export.go#L868-L904","documentation":"When copying a resource file/folder into the temporary export directory fails, ExportResources wraps the underlying OS error with the localized template Conf.Language(14) ('copy resource failed: %s'). The original error (permissions, missing file, disk full, name collision) is embedded via fmt.Errorf so the log records the source and destination while the user sees a friendly message.","triggerScenarios":"copyExportResource returns an error for any resource in the list — source deleted between listing and copy, read permission denied, destination write failure in TempDir/export, directory walk error, or disk quota exhausted.","commonSituations":"Asset file removed or renamed after the export list was built; read-only or AV-scanner-locked files on Windows; temp directory on a full disk; exporting a directory containing files the process cannot read.","solutions":["Read the wrapped %s detail to find the underlying cause (missing file, permission, disk space)","Verify the source resource still exists and is readable before exporting","Free disk space / check write permissions on the temp export directory","Retry after resolving file locks (close apps holding the file, exclude from AV scanning)"],"exampleFix":"// before\n// source may have been deleted\nawait exportResources(staleAssetPaths);\n// after\nconst existing = staleAssetPaths.filter(p => fs.existsSync(path.join(workspaceDir, p)));\nawait exportResources(existing);","handlingStrategy":"try-catch","validationCode":"for _, p := range paths {\n    if _, err := os.Stat(filepath.Join(util.WorkspaceDir, p)); err != nil {\n        return fmt.Errorf(\"resource missing before export: %s\", p)\n    }\n}","typeGuard":null,"tryCatchPattern":"_, err := model.ExportResources(paths, name)\nif err != nil {\n    var msg string\n    fmt.Sscanf(err.Error(), Conf.Language(14), &msg) // unwrap %s detail\n    log.Printf(\"export copy failed: %s\", msg)\n}","preventionTips":["Verify each source path exists right before exporting","Check free disk space in the temp directory","Handle Windows file locks (AV, search indexer) on asset folders"],"tags":["file-copy","filesystem","export","permissions"],"backgroundTag":"file-copy-failed","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}