{"record":{"id":"1ceac9a9bcbc133d","repo":"slimtoolkit/slim","slug":"s-s-partial-copy-d-d","errorCode":null,"errorMessage":"%s -> %s: partial copy - %d/%d","messagePattern":"(.+?) -> (.+?): partial copy - (.+?)/(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/util/fsutil/fsutil.go","lineNumber":588,"sourceCode":"\t}\n\n\td, err := os.Create(dst)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif srcFileInfo.Size() > 0 {\n\t\twritten, err := io.Copy(d, s)\n\t\tif err != nil {\n\t\t\td.Close()\n\t\t\treturn err\n\t\t}\n\n\t\tif written != srcFileInfo.Size() {\n\t\t\tlog.Debugf(\"CopyRegularFile(%v,%v,%v) - copy data mismatch - %v/%v\",\n\t\t\t\tsrc, dst, makeDir, written, srcFileInfo.Size())\n\t\t\td.Close()\n\t\t\treturn fmt.Errorf(\"%s -> %s: partial copy - %d/%d\",\n\t\t\t\tsrc, dst, written, srcFileInfo.Size())\n\t\t}\n\t}\n\n\t//Need to close dst file before chmod works the right way\n\tif err := d.Close(); err != nil {\n\t\tlog.Debugf(\"CopyRegularFile() - d.Close error - %v\", err)\n\t\treturn err\n\t}\n\n\tif clone {\n\t\tif err := os.Chmod(dst, srcFileInfo.Mode()); err != nil {\n\t\t\tlog.Warnf(\"CopyRegularFile(%v,%v) - unable to set mode\", src, dst)\n\t\t\treturn err\n\t\t}\n\n\t\tif sysStat, ok := srcFileInfo.Sys().(*syscall.Stat_t); ok {\n\t\t\tssi := SysStatInfo(sysStat)","sourceCodeStart":570,"sourceCodeEnd":606,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/util/fsutil/fsutil.go#L570-L606","documentation":"fsutil.CopyRegularFile verifies that the number of bytes written to the destination equals the source file size; on mismatch it closes the file and returns this 'partial copy' error naming src, dst, and written/expected counts. It guards against silently producing truncated copies of artifacts.","triggerScenarios":"CopyRegularFile's io.Copy (or write loop) completes but reports fewer bytes than srcFileInfo.Size() — short writes or read errors swallowed mid-copy.","commonSituations":"Destination filesystem full (NFS/tmpfs quota); source file modified/truncated during copy; disk I/O errors; copying artifacts onto a volume that ran out of space mid-transfer.","solutions":["Check destination free space (df -h on the dst volume) and free space or use a larger volume","Re-run the copy; transient I/O or concurrent-write issues usually resolve","Verify the source file wasn't being written concurrently; copy a stable snapshot instead","Check dmesg for I/O errors on the destination device; replace failing storage"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before copying, ensure space and source stability\nsrcInfo, _ := os.Stat(src)\nusage := freeSpace(filepath.Dir(dst))\nif usage < uint64(srcInfo.Size()) { return errors.New(\"insufficient space\") }","typeGuard":null,"tryCatchPattern":"if err := fsutil.CopyRegularFile(src, dst, makeDir); err != nil {\n    if strings.Contains(err.Error(), \"partial copy\") {\n        os.Remove(dst) // remove truncated artifact\n        // check disk space / I/O, then retry\n        err = fsutil.CopyRegularFile(src, dst, makeDir)\n    }\n}","preventionTips":["Check destination free space before bulk artifact copies","Copy stable snapshots, not files being written concurrently","Verify copied artifacts (size/checksum) after transfer","Alert on dmesg I/O errors for destination volumes"],"tags":["filesystem","copy","io"],"backgroundTag":"partial-file-copy","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}