{"record":{"id":"5eb10f62a0f0b3ba","repo":"yorukot/superfile","slug":"failed-to-check-partitions-w","errorCode":null,"errorMessage":"failed to check partitions: %w","messagePattern":"failed to check partitions: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/internal/file_operations.go","lineNumber":52,"sourceCode":"\t}\n\n\t// For Unix-like systems, we use the same path to check the root partition\n\treturn filepath.VolumeName(absPath1) == filepath.VolumeName(absPath2), nil\n}\n\n// getDriveLetter extracts the drive letter from a Windows path\nfunc getDriveLetter(path string) string {\n\t// Windows paths are usually like \"C:\\path\\to\\file\"\n\t// So we need to extract the drive letter (e.g., \"C\")\n\treturn strings.ToUpper(string(path[0]))\n}\n\n// moveElement moves a file or directory efficiently\nfunc moveElement(src, dst string) error {\n\t// Check if source and destination are on the same partition\n\tsameDev, err := isSamePartition(src, dst)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to check partitions: %w\", err)\n\t}\n\n\t// If on the same partition, attempt to rename (which will use the same inode)\n\tif sameDev {\n\t\tif err = os.Rename(src, dst); err == nil {\n\t\t\treturn nil\n\t\t}\n\t\t// If rename fails, fall back to copy+delete\n\t}\n\n\t// If on different partitions or rename failed, fall back to copy+delete\n\terr = copyElement(src, dst)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to copy: %w\", err)\n\t}\n\n\terr = os.RemoveAll(src)\n\tif err != nil {","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/yorukot/superfile/blob/b72f550bc6e75913f48eb49fdd258e1a2df2fe88/src/internal/file_operations.go#L34-L70","documentation":"moveElement first asks isSamePartition whether source and destination share a filesystem; any error from that check is wrapped as 'failed to check partitions'. This is a wrapper around the underlying abs-path/ partition-detection errors, so the root cause is in the %w chain.","triggerScenarios":"moveElement(src, dst) called with paths whose absolute resolution or partition detection fails (e.g. Getwd failure on relative paths, or underlying OS stat/device checks erroring).","commonSituations":"Moving a file whose cwd was deleted; destination on a flaky mount point (network drive dropped); Windows drive-letter lookup on a malformed path.","solutions":["Read the wrapped %w error for the real cause (abs path vs device check).","Use absolute, well-formed paths for both src and dst.","Verify the destination mount is accessible (df / ls the mount).","Retry after restoring the working directory or remounting the target volume."],"exampleFix":"// before\nmoveElement(\"file.txt\", \"/mnt/netdrv/dest\") // mount down\n// after\n// remount /mnt/netdrv, or pick an accessible destination\nmoveElement(\"/data/file.txt\", \"/mnt/netdrv/dest\")","handlingStrategy":"validation","validationCode":"for _, p := range []string{src, dst} {\n    if !filepath.IsAbs(p) {\n        if _, err := os.Getwd(); err != nil {\n            return fmt.Errorf(\"cwd unavailable, resolve %q to absolute first\", p)\n        }\n    }\n}\nif _, err := os.Stat(filepath.Dir(dst)); err != nil {\n    return fmt.Errorf(\"destination parent inaccessible: %w\", err)\n}","typeGuard":"func pathsResolvable(paths ...string) error {\n    for _, p := range paths {\n        if filepath.IsAbs(p) { continue }\n        if _, err := os.Getwd(); err != nil { return err }\n    }\n    return nil\n}","tryCatchPattern":"if err := moveElement(src, dst); err != nil {\n    if strings.Contains(err.Error(), \"failed to check partitions\") {\n        // fall back to explicit copy+delete with fully resolved paths\n        return manualMove(filepathAbs(src), filepathAbs(dst))\n    }\n    return err\n}","preventionTips":["Pre-check both paths with os.Stat and filepath.Abs before moving.","Verify mount points (especially network drives) are alive before cross-device moves.","Unwrap the error chain (errors.Unwrap / %w) to diagnose the real cause.","Retry transient mount failures with backoff before giving up."],"tags":["filesystem","move","paths"],"backgroundTag":"partition-check-failed","analyzedSha":"b72f550bc6e75913f48eb49fdd258e1a2df2fe88","analyzedAt":"2026-09-01T04:38:08.254Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}