@@ -7,17 +7,20 @@ import com.mairwunnx.projectessentials.core.api.v1.extensions.empty
7
7
import com.mairwunnx.projectessentials.core.api.v1.messaging.MessagingAPI
8
8
import com.mairwunnx.projectessentials.core.api.v1.permissions.hasPermission
9
9
import kotlinx.coroutines.*
10
+ import net.lingala.zip4j.ZipFile
11
+ import net.lingala.zip4j.model.ZipParameters
12
+ import net.lingala.zip4j.model.enums.CompressionLevel
10
13
import net.minecraftforge.api.distmarker.Dist
11
14
import net.minecraftforge.fml.DistExecutor
12
15
import net.minecraftforge.fml.server.ServerLifecycleHooks.getCurrentServer
13
16
import org.apache.logging.log4j.LogManager
14
17
import org.apache.logging.log4j.MarkerManager
15
- import org.zeroturnaround.zip.ZipUtil
16
18
import java.io.File
17
19
import java.text.SimpleDateFormat
18
20
import java.util.*
19
21
import kotlin.system.measureTimeMillis
20
22
23
+
21
24
object BackupManager {
22
25
private val logger = LogManager .getLogger()
23
26
private val marker = MarkerManager .getMarker(" BACKUP" )
@@ -102,9 +105,20 @@ object BackupManager {
102
105
val path = outPath(file).also { path -> logger.debug(" Saving backup to $path " ) }
103
106
val inPath = inPath()
104
107
measureTimeMillis {
105
- ZipUtil .pack(
106
- File (inPath), File (path), backupConfiguration.backupCompressionLevel
107
- )
108
+ ZipFile (path).addFolder(File (inPath), ZipParameters ().apply {
109
+ compressionLevel = CompressionLevel .values().find { lvl ->
110
+ lvl.level == backupConfiguration.backupCompressionLevel
111
+ }
112
+ isIncludeRootFolder = true
113
+ })
114
+ if (backupConfiguration.backupConfigurations) {
115
+ ZipFile (path).addFolder(File (" config" ), ZipParameters ().apply {
116
+ compressionLevel = CompressionLevel .values().find { lvl ->
117
+ lvl.level == backupConfiguration.backupCompressionLevel
118
+ }
119
+ isIncludeRootFolder = true
120
+ })
121
+ }
108
122
}.also { time -> logger.debug(" Backup saved to $path for ${time / 1000 } seconds" ) }
109
123
notifyPlayer()
110
124
}
0 commit comments