{"record":{"id":"f77e70f2ca8079cb","repo":"siyuan-note/siyuan","slug":"copy-data-failed","errorCode":null,"errorMessage":"copy data failed","messagePattern":"copy data failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"kernel/model/import.go","lineNumber":1140,"sourceCode":"\t\t\tif strings.HasPrefix(d.Name(), \".\") {\n\t\t\t\treturn filepath.SkipDir\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\n\t\tif !strings.HasSuffix(d.Name(), \".sy\") {\n\t\t\treturn nil\n\t\t}\n\n\t\tp := strings.TrimPrefix(path, unzipRootPath)\n\t\tp = filepath.ToSlash(p)\n\t\ttreePaths = append(treePaths, p)\n\t\treturn nil\n\t})\n\n\tif err = filelock.Copy(unzipRootPath, targetDir); err != nil {\n\t\tlogging.LogErrorf(\"copy data dir from [%s] to [%s] failed: %s\", unzipRootPath, util.DataDir, err)\n\t\terr = errors.New(\"copy data failed\")\n\t\treturn\n\t}\n\n\tboxAbsPath := filepath.Join(util.DataDir, boxID)\n\timportedAvIDs := map[string]struct{}{}\n\tfor _, importedAvID := range avIDs {\n\t\timportedAvIDs[importedAvID] = struct{}{}\n\t}\n\tfor _, treePath := range treePaths {\n\t\tabsPath := filepath.Join(targetDir, treePath)\n\t\tp := strings.TrimPrefix(absPath, boxAbsPath)\n\t\tp = filepath.ToSlash(p)\n\t\tcache.RemoveTreeDataInBox(util.GetTreeID(p), boxID)\n\t\tcache.RemoveDocIALInBox(p, boxID)\n\t\ttree, err := filesys.LoadTree(boxID, p, luteEngine)\n\t\tif err != nil {\n\t\t\tlogging.LogErrorf(\"load tree [%s] failed: %s\", treePath, err)\n\t\t\tcontinue","sourceCodeStart":1122,"sourceCodeEnd":1158,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/import.go#L1122-L1158","documentation":"When importing a whole-data zip (ImportData path within importSY0's flow), the unzipped tree is copied from unzipRootPath into the workspace's data directory with filelock.Copy. If the copy fails, the error is replaced by the generic 'copy data failed' message, hiding the underlying cause in the log. This copy step materializes the imported notebook's documents, assets and .siyuan metadata into the live workspace.","triggerScenarios":"Importing a data archive whose unzip succeeded but whose copy into util.DataDir failed — e.g. insufficient disk space, a file in the archive colliding with a locked destination file, or OS permission errors inside the workspace data dir.","commonSituations":"1) Disk full when importing a large archive. 2) Another SiYuan instance holds locks in the data directory on Windows. 3) Data dir restored from backup with restrictive ownership/permissions. 4) Quota-exceeded cloud-synced workspace folder.","solutions":["Check the kernel log for the 'copy data dir from [...] to [...] failed' line to identify the exact file and OS error.","Free disk space (or expand the volume) so the workspace data partition has room for the archive's contents.","Close other SiYuan instances / exclude the workspace from antivirus indexing, then retry.","Fix permissions on the workspace data directory so the kernel process can create files there, and retry the import."],"exampleFix":"// before\nif err = filelock.Copy(unzipRootPath, targetDir); err != nil {\n    err = errors.New(\"copy data failed\")\n}\n// after\nif err = filelock.Copy(unzipRootPath, targetDir); err != nil {\n    err = fmt.Errorf(\"copy data dir from [%s] to [%s] failed: %w\", unzipRootPath, targetDir, err)\n}","handlingStrategy":"try-catch","validationCode":"const free = await getDiskFree(workspaceDir); // ensure headroom ≥ archive size * 2\nif (free < 2 * archiveSize) { throw new Error('insufficient disk space for import'); }","typeGuard":null,"tryCatchPattern":"try {\n  await importData(src);\n} catch (e) {\n  if (e.msg === 'copy data failed') {\n    console.error('Check kernel log \"copy data dir from ... failed\"; free disk space / clear file locks, then retry');\n  }\n  throw e;\n}","preventionTips":["Verify free disk space before large imports (archive needs roughly 2x its size)","Close other kernel instances and pause sync clients during import","Fix data-dir ownership/permissions after restoring workspaces from backups"],"tags":["filesystem","copy","import","siyuan"],"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"}