{"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":"error","filePath":"kernel/model/import.go","lineNumber":866,"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":848,"sourceCodeEnd":884,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/import.go#L848-L884","documentation":"Thrown by ImportSYZip when filelock.Copy fails copying the unzipped content from the temporary extraction directory (unzipRootPath) to the target notebook directory (targetDir under data/boxID/baseTargetPath). This copy happens after block-ID regeneration and path renaming, moving the processed .sy files and assets into their final location. The underlying copy error is logged with source and destination paths.","triggerScenarios":"Calling ImportSYZip where filelock.Copy(unzipRootPath, targetDir) returns a non-nil error at import.go:864-867. The target directory was created with os.MkdirAll just before, so the failure is typically I/O-related rather than a missing parent.","commonSituations":"Disk full during the copy operation. Permission denied on the target notebook directory. A file in the source is locked by another process. Symlink or special file in the unzipped content that the copy routine cannot handle. Network-mounted data directory with intermittent connectivity.","solutions":["Free disk space on the volume containing the SiYuan data directory.","Check file permissions on data/boxID and its parent directories.","Close other applications that may have files open in the data directory.","Inspect the kernel log for the detailed copy error (logged at import.go:865 with unzipRootPath and util.DataDir).","If using a network or cloud-synced data directory, verify connectivity and pause sync tools during import."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before ImportSYZip, verify target directory has enough free space\nfunc checkFreeSpace(targetDir string, zipPath string) error {\n    var stat unix.Statfs_t\n    if err := unix.Statfs(targetDir, &stat); err != nil {\n        return err\n    }\n    freeBytes := stat.Bavail * uint64(stat.Bsize)\n    zipInfo, _ := os.Stat(zipPath)\n    needed := uint64(zipInfo.Size()) * 3 // uncompressed estimate\n    if freeBytes < needed {\n        return fmt.Errorf(\"insufficient disk space: have %d bytes, need ~%d\", freeBytes, needed)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"createdBoxID, err := model.ImportSYZip(boxID, localPath, toPath)\nif err != nil && err.Error() == \"copy data failed\" {\n    // Surface a user-friendly message with disk space hint\n    logging.LogErrorf(\"copy failed during .sy.zip import: check disk space and permissions\")\n}","preventionTips":["Check available disk space before importing — the uncompressed size can be 3-5x the zip size.","Verify write permissions on the data directory.","Pause cloud sync tools during import to avoid file lock conflicts.","Monitor disk health to catch failing drives before they cause I/O errors."],"tags":["import","filesystem","sy-zip","copy","io"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}