mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 10:25:06 -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) {
|
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.info(String.format("Log level changed from %s to %s", Log.level, level));
|
||||||
Log.level = level;
|
Log.level = level;
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,14 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.util;
|
package de.bixilon.minosoft.util;
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.logging.Log;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
public final class FolderUtil {
|
public final class FolderUtil {
|
||||||
|
|
||||||
@ -31,8 +34,14 @@ public final class FolderUtil {
|
|||||||
}
|
}
|
||||||
File out = new File(to + File.separator + entry);
|
File out = new File(to + File.separator + entry);
|
||||||
if (out.exists()) {
|
if (out.exists()) {
|
||||||
|
// check
|
||||||
|
if (Files.mismatch(Path.of(entryFile.getPath()), Path.of(out.getPath())) == -1) {
|
||||||
|
// identically
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// move file to an other location and re extract
|
||||||
|
moveFileToOld(out);
|
||||||
|
}
|
||||||
File outFolder = new File(out.getParent());
|
File outFolder = new File(out.getParent());
|
||||||
if (!outFolder.exists()) {
|
if (!outFolder.exists()) {
|
||||||
outFolder.mkdirs();
|
outFolder.mkdirs();
|
||||||
@ -40,4 +49,14 @@ public final class FolderUtil {
|
|||||||
Files.copy(new FileInputStream(entryFile), out.toPath());
|
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