Added option to compress file backups#8396
Added option to compress file backups#8396Pesekjak wants to merge 4 commits intoSkriptLang:dev/featurefrom
Conversation
|
iirc Skript's contribution requirements requires that all Edit: just for |
They can be omitted for single line ifs without elses |
| String newFileName = name + "_" + getBackupSuffix() + ext; | ||
| boolean compress = SkriptConfig.compressBackups.value(); | ||
| if (compress) | ||
| newFileName += ".gz"; |
There was a problem hiding this comment.
.zip is more accessible, why pick gz?
There was a problem hiding this comment.
are they not both equally accessible?
There was a problem hiding this comment.
I agree with fusezion, also gzip is better suited for compression of single files
There was a problem hiding this comment.
Mojang uses .gz for the log files
src/main/resources/config.sk
Outdated
| # Whether Skript should log the usage of effect commands. | ||
| # They will be logged as [INFORMATION] in this format: '<player> issued effect command: <command>' | ||
|
|
||
| compress backups: false |
There was a problem hiding this comment.
what are the downsides of setting this to true by default?
There was a problem hiding this comment.
none (except you don't have to decompress to access) but I mainly wanted to keep the default behaviour the same as before. would you change it to true by default?
There was a problem hiding this comment.
I would change it true by default, if you're trying to access and/or modify the variables file you'd have to know what you're doing in which case unzipping the file isn't an issue.
Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>
|
I recommend throwing some compression onto the GZip because the default compression isn't going to do much. private static class GZIPOutputStreamWithLevel extends GZIPOutputStream {
public GZIPOutputStreamWithLevel(OutputStream out, int level) throws IOException {
super(out);
this.def.setLevel(level);
}
}try (OutputStream os = Files.newOutputStream(backup); GZIPOutputStreamWithLevel gzipOs = new GZIPOutputStreamWithLevel(os, Deflater.BEST_COMPRESSION)) {
Files.copy(source, gzipOs);
}You can also use Apache's GzipCompressorOutputStream or TarArchiveOutputStream Mojang uses the TarArchiveOutputStream for large files |
Problem
Backups of variables.csv can take up a lot of space for some users.
Solution
There is now an option in config to turn on automatic compression of those files. This also applies to other file backups (lang and config). I also refactored the backup method to replace the legacy code.
Testing Completed
I tested this manually, I believe we don't need automated test for this.
Completes: #8083
Related: none
AI assistance: none