{"record":{"id":"2e6bccc6cb504021","repo":"siyuan-note/siyuan","slug":"export-failed-s","errorCode":null,"errorMessage":"Export failed: %s","messagePattern":"Export failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/export.go","lineNumber":727,"sourceCode":"\tzipPath = \"/export/\" + url.PathEscape(filepath.Base(zipPath))\n\treturn\n}\n\nfunc exportData(exportFolder string) (zipPath string, err error) {\n\tFlushTxQueue()\n\n\tlogging.LogInfof(\"exporting data...\")\n\n\tbaseFolderName := \"data-\" + util.CurrentTimeSecondsStr()\n\tif err = os.MkdirAll(exportFolder, 0755); err != nil {\n\t\tlogging.LogErrorf(\"create export temp folder failed: %s\", err)\n\t\treturn\n\t}\n\n\tdata := filepath.Join(util.WorkspaceDir, \"data\")\n\tif err = filelock.Copy(data, exportFolder); err != nil {\n\t\tlogging.LogErrorf(\"copy data dir from [%s] to [%s] failed: %s\", data, baseFolderName, err)\n\t\terr = fmt.Errorf(Conf.Language(14), err.Error())\n\t\treturn\n\t}\n\n\tzipPath = exportFolder + \".zip\"\n\tzip, err := gulu.Zip.Create(zipPath)\n\tif err != nil {\n\t\tlogging.LogErrorf(\"create export data zip [%s] failed: %s\", exportFolder, err)\n\t\treturn\n\t}\n\n\tzipCallback := func(filename string) {\n\t\tutil.PushEndlessProgress(Conf.language(65) + \" \" + fmt.Sprintf(Conf.language(253), filename))\n\t}\n\n\tif err = zip.AddDirectory(baseFolderName, exportFolder, zipCallback); err != nil {\n\t\tlogging.LogErrorf(\"create export data zip [%s] failed: %s\", exportFolder, err)\n\t\treturn\n\t}","sourceCodeStart":709,"sourceCodeEnd":745,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/export.go#L709-L745","documentation":"Raised in exportData when filelock.Copy fails copying the workspace data directory into the temp export folder. The raw copy error is wrapped with Conf.Language(14) ('Export failed: %s'). This is the heavy step that duplicates the entire data tree before zipping, so it fails on permission errors, disk-full mid-copy, or a locked/inaccessible source file.","triggerScenarios":"POST /api/export/exportData or exportDataInFolder where filelock.Copy(data, exportFolder) errors — file held open by another process (Windows), permission denied on a file inside data/, disk fills up mid-copy (the space check is heuristic and can underestimate), or the source tree contains a path too long on Windows.","commonSituations":"Antivirus or backup software locking files in the data dir on Windows. A sync operation writing concurrently. A corrupted file with wrong permissions. Disk space exhausted despite the pre-check (e.g. assets grew between check and copy).","solutions":["Check the kernel log for the underlying copy error message (the wrapped %s) — it names the file and the OS error.","Close other programs (sync, antivirus, backup) that may lock files in the workspace data directory and retry.","Run SiYuan as a user with full permissions on the workspace directory.","Free more disk space — the pre-check can underestimate concurrent writes.","Shorten very deep paths or move the workspace closer to the filesystem root on Windows."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := model.ExportData(); err != nil {\n    if strings.HasPrefix(err.Error(), Conf.Language(14)[:13]) { // 'Export failed:'\n        // inspect underlying cause in log (export.go:726), then retry after fixing perms/space\n    }\n}","preventionTips":["Close sync/antivirus/backup tools that lock workspace files before exporting.","Ensure the kernel process has full permissions on the data directory.","Keep ample free disk space beyond the pre-check estimate (concurrent writes can grow data).","On Windows, shorten deep asset paths to avoid copy failures."],"tags":["filesystem","export","data-export","file-copy","permissions"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}