mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 17:37:58 -04:00
1.16.3-rc1, assets copying: check if files are identically, else force extract (rename to .old)
This commit is contained in:
parent
652e0c3058
commit
06abdb64a8
@ -145,6 +145,9 @@ public class Log {
|
||||
}
|
||||
|
||||
public static void setLevel(LogLevels level) {
|
||||
if (Log.level == level) {
|
||||
return;
|
||||
}
|
||||
Log.info(String.format("Log level changed from %s to %s", Log.level, level));
|
||||
Log.level = level;
|
||||
}
|
||||
|
@ -13,11 +13,14 @@
|
||||
|
||||
package de.bixilon.minosoft.util;
|
||||
|
||||
import de.bixilon.minosoft.logging.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public final class FolderUtil {
|
||||
|
||||
@ -31,7 +34,13 @@ public final class FolderUtil {
|
||||
}
|
||||
File out = new File(to + File.separator + entry);
|
||||
if (out.exists()) {
|
||||
continue;
|
||||
// check
|
||||
if (Files.mismatch(Path.of(entryFile.getPath()), Path.of(out.getPath())) == -1) {
|
||||
// identically
|
||||
continue;
|
||||
}
|
||||
// move file to an other location and re extract
|
||||
moveFileToOld(out);
|
||||
}
|
||||
File outFolder = new File(out.getParent());
|
||||
if (!outFolder.exists()) {
|
||||
@ -40,4 +49,14 @@ public final class FolderUtil {
|
||||
Files.copy(new FileInputStream(entryFile), out.toPath());
|
||||
}
|
||||
}
|
||||
|
||||
private static void moveFileToOld(File file) {
|
||||
File newFile = new File(file.getAbsolutePath() + ".old");
|
||||
if (newFile.exists()) {
|
||||
newFile.delete();
|
||||
Log.verbose(String.format("Deleted file: %s", newFile.getAbsoluteFile()));
|
||||
}
|
||||
file.renameTo(newFile);
|
||||
Log.verbose(String.format("Renamed %s to: %s", newFile.getAbsoluteFile(), newFile.getName()));
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user