slimtoolkit/slim · error

%s -> %s: partial copy - %d/%d

Error message

%s -> %s: partial copy - %d/%d

What it means

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.

Source

Thrown at pkg/util/fsutil/fsutil.go:588

	}

	d, err := os.Create(dst)
	if err != nil {
		return err
	}

	if srcFileInfo.Size() > 0 {
		written, err := io.Copy(d, s)
		if err != nil {
			d.Close()
			return err
		}

		if written != srcFileInfo.Size() {
			log.Debugf("CopyRegularFile(%v,%v,%v) - copy data mismatch - %v/%v",
				src, dst, makeDir, written, srcFileInfo.Size())
			d.Close()
			return fmt.Errorf("%s -> %s: partial copy - %d/%d",
				src, dst, written, srcFileInfo.Size())
		}
	}

	//Need to close dst file before chmod works the right way
	if err := d.Close(); err != nil {
		log.Debugf("CopyRegularFile() - d.Close error - %v", err)
		return err
	}

	if clone {
		if err := os.Chmod(dst, srcFileInfo.Mode()); err != nil {
			log.Warnf("CopyRegularFile(%v,%v) - unable to set mode", src, dst)
			return err
		}

		if sysStat, ok := srcFileInfo.Sys().(*syscall.Stat_t); ok {
			ssi := SysStatInfo(sysStat)

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Check destination free space (df -h on the dst volume) and free space or use a larger volume
  2. Re-run the copy; transient I/O or concurrent-write issues usually resolve
  3. Verify the source file wasn't being written concurrently; copy a stable snapshot instead
  4. Check dmesg for I/O errors on the destination device; replace failing storage
Defensive patterns

Strategy: try-catch

Validate before calling

// before copying, ensure space and source stability
srcInfo, _ := os.Stat(src)
usage := freeSpace(filepath.Dir(dst))
if usage < uint64(srcInfo.Size()) { return errors.New("insufficient space") }

Try / catch

if err := fsutil.CopyRegularFile(src, dst, makeDir); err != nil {
    if strings.Contains(err.Error(), "partial copy") {
        os.Remove(dst) // remove truncated artifact
        // check disk space / I/O, then retry
        err = fsutil.CopyRegularFile(src, dst, makeDir)
    }
}

Prevention

When it happens

Trigger: CopyRegularFile's io.Copy (or write loop) completes but reports fewer bytes than srcFileInfo.Size() — short writes or read errors swallowed mid-copy.

Common situations: 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.

Related errors


AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31). Data as JSON: /api/errors/1ceac9a9bcbc133d. Report an issue: GitHub.