Repaired Backups have a "." directory #7, and updated minecraft version.
							parent
							
								
									f8d2a69743
								
							
						
					
					
						commit
						13436baaec
					
				|  | @ -1,14 +1,14 @@ | |||
| # Done to increase the memory available to gradle. | ||||
| org.gradle.jvmargs=-Xmx1G | ||||
| 
 | ||||
| minecraft_version=20w12a | ||||
| yarn_mappings=20w12a+build.19 | ||||
| loader_version=0.7.8+build.189 | ||||
| minecraft_version=20w14a | ||||
| yarn_mappings=20w14a+build.1 | ||||
| loader_version=0.7.9+build.190 | ||||
| 
 | ||||
| #Fabric api | ||||
| fabric_version=0.5.5+build.311-1.16 | ||||
| fabric_version=0.5.7+build.314-1.16 | ||||
| 
 | ||||
| # Mod Properties | ||||
| 	mod_version = 1.1.0-1.16 | ||||
| 	mod_version = 1.1.1-1.15 | ||||
| 	maven_group = net.szum123321 | ||||
| 	archives_base_name = textile_backup | ||||
|  | @ -52,7 +52,7 @@ public class BackupHelper { | |||
|         if(save) | ||||
|             server.save(true, false, false); | ||||
| 
 | ||||
|         MakeBackupThread thread = new MakeBackupThread(server, ctx, comment); | ||||
|         Thread thread = new Thread(new MakeBackupThread(server, ctx, comment)); | ||||
| 
 | ||||
|         thread.start(); | ||||
|     } | ||||
|  |  | |||
|  | @ -26,7 +26,7 @@ import java.io.File; | |||
| import java.io.FileInputStream; | ||||
| import java.io.FileOutputStream; | ||||
| import java.io.IOException; | ||||
| import java.util.Objects; | ||||
| import java.nio.file.Files; | ||||
| import java.util.zip.ZipEntry; | ||||
| import java.util.zip.ZipOutputStream; | ||||
| 
 | ||||
|  | @ -34,31 +34,34 @@ public class Compressor { | |||
|     public static void createArchive(File in, File out, ServerCommandSource ctx){ | ||||
|         Utilities.log("Starting compression...", ctx); | ||||
| 
 | ||||
|         try(ZipOutputStream arc = new ZipOutputStream(new FileOutputStream(out))) { | ||||
|         try { | ||||
|             File input = in.getCanonicalFile(); | ||||
| 
 | ||||
|             ZipOutputStream arc = new ZipOutputStream(new FileOutputStream(out)); | ||||
| 
 | ||||
|             arc.setLevel(TextileBackup.config.compression); | ||||
|             addToArchive(arc, in, "."); | ||||
| 
 | ||||
|             int rootPathLength = input.toString().length() + 1; | ||||
| 
 | ||||
|             Files.walk(input.toPath()).filter(path -> !path.equals(input.toPath()) && path.toFile().isFile()).forEach(path -> { | ||||
|                 try{ | ||||
|                     File file = path.toAbsolutePath().toFile(); | ||||
| 
 | ||||
|                     ZipEntry entry = new ZipEntry(file.getAbsolutePath().substring(rootPathLength)); | ||||
|                     arc.putNextEntry(entry); | ||||
|                     entry.setSize(file.length()); | ||||
|                     IOUtils.copy(new FileInputStream(file), arc); | ||||
|                     arc.closeEntry(); | ||||
|                 }catch (IOException e){ | ||||
|                     TextileBackup.logger.error(e.getMessage()); | ||||
|                 } | ||||
|             }); | ||||
| 
 | ||||
|             arc.close(); | ||||
|         } catch (IOException e) { | ||||
|             TextileBackup.logger.error(e.getMessage()); | ||||
|         } | ||||
| 
 | ||||
|         Utilities.log("Compression finished", ctx); | ||||
|     } | ||||
| 
 | ||||
|     private static void addToArchive(ZipOutputStream out, File file, String dir) throws IOException { | ||||
|         String name = dir + File.separator + file.getName(); | ||||
| 
 | ||||
|         if(file.isFile()){ | ||||
|             ZipEntry entry = new ZipEntry(name); | ||||
|             out.putNextEntry(entry); | ||||
|             entry.setSize(file.length()); | ||||
|             IOUtils.copy(new FileInputStream(file), out); | ||||
|             out.closeEntry(); | ||||
|         }else if(file.isDirectory() && file.listFiles() != null){ | ||||
|             for(File f: Objects.requireNonNull(file.listFiles())){ | ||||
|                 if(f != null){ | ||||
|                     addToArchive(out, f, name); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -26,10 +26,10 @@ import java.io.File; | |||
| import java.io.IOException; | ||||
| import java.time.LocalDateTime; | ||||
| 
 | ||||
| public class MakeBackupThread extends Thread { | ||||
|     MinecraftServer server; | ||||
|     ServerCommandSource ctx; | ||||
|     String comment; | ||||
| public class MakeBackupThread implements Runnable { | ||||
|     private MinecraftServer server; | ||||
|     private ServerCommandSource ctx; | ||||
|     private String comment; | ||||
| 
 | ||||
|     public MakeBackupThread(MinecraftServer server, ServerCommandSource ctx, String comment){ | ||||
|         this.server = server; | ||||
|  |  | |||
|  | @ -7,6 +7,11 @@ import net.szum123321.textile_backup.TextileBackup; | |||
| import java.time.format.DateTimeFormatter; | ||||
| 
 | ||||
| public class Utilities { | ||||
| 	public static boolean isWindows(){ | ||||
| 		String os = System.getProperty("os.name"); | ||||
| 		return os.toLowerCase().startsWith("win"); | ||||
| 	} | ||||
| 
 | ||||
| 	public static DateTimeFormatter getDateTimeFormatter(){ | ||||
| 		if(!TextileBackup.config.dateTimeFormat.equals("")) | ||||
| 			return DateTimeFormatter.ofPattern(TextileBackup.config.dateTimeFormat); | ||||
|  | @ -15,8 +20,7 @@ public class Utilities { | |||
| 	} | ||||
| 
 | ||||
| 	public static DateTimeFormatter getBackupDateTimeFormatter(){ | ||||
| 		String os = System.getProperty("os.name"); | ||||
| 		if(os.toLowerCase().startsWith("win")){ | ||||
| 		if(isWindows()){ | ||||
| 			return DateTimeFormatter.ofPattern("dd.MM.yyyy_HH-mm-ss"); | ||||
| 		} else { | ||||
| 			return DateTimeFormatter.ofPattern("dd.MM.yyyy_HH:mm:ss"); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue