Patch download to work with symlinks (#736)

* Fix Download to work with symlinks

- Create SymlinkWalker
    * isPathSymbolic for whether any part of the path is symbolic, existing or not.
    * getRealPath for obtaining absolute, real path.
- Change Download to use SymlinkWalker
- Add in a new test for testing with symlinks

* Refactor
Switch to using Guava method for creating directories

* Fix import

* Alter test and fix arguments

* Forgot a def

* Fix method argument

* Change argument to child file

* Bump
This commit is contained in:
Phoenix-Starlight
2022-11-03 11:26:49 -07:00
committed by GitHub
parent ddf4605845
commit 03e1369adc
2 changed files with 21 additions and 2 deletions

View File

@@ -24,6 +24,8 @@
package net.fabricmc.loom.util.download;
import static com.google.common.io.Files.createParentDirs;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -160,7 +162,7 @@ public class Download {
}
try {
Files.createDirectories(output.getParent());
createParentDirs(output.toFile());
Files.deleteIfExists(output);
} catch (IOException e) {
throw error(e, "Failed to prepare path for download");