FabricMC / fabric-loom

Gradle build system plugin used to automate the setup of a minecraft mod development environment.
MIT License
233 stars 201 forks source link

Downloader: Protect against partially downloaded files. #954

Closed modmuss50 closed 11 months ago

modmuss50 commented 11 months ago

Seen one or two users on Discord reporting loom only downloading parts of the file, I think this is quite rare. This change should protect against failed or cancled downloads by ensuring that the output file only exists in its final state.

  1. Download the file initially to a <filename>.part file
  2. Once the file has been fully written, create a hard link to the destination file.
  3. And then remove the part file, this ensures that the output file only exists in fully populated state.