Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Its API is similar to os.Copy, but it detects consecutive zeros, and replaces them with a seek. This should be enough to poke a hole in the file being written, and not occupy unneeded disk space. This works by copying 4kiB chunks at a time, and checking if these 4kiB are all 0s or not. The chunk size is fairly arbitrary, and can be tweaked if needed. If a set of consecutive 0s is not aligned on a 4kiB block, then it won't be detected. This API is needed since we started using raw images on macOS. This will avoid using unnecessary disk space when the 31GB disk image does not contain a lot of data and is mostly 0s. It needs to be used in 2 different places, when extracting the bundle from an archive, and when copying the disk image from the bundle to the machine directory.
- Loading branch information