Added option to compress file backups by Pesekjak · Pull Request #8396 · SkriptLang/Skript
Conversation
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
iirc Skript's contribution requirements requires that all {} are placed after , if, elsefor, etc
Edit: just for for appearantly
iirc Skript's contribution requirements requires that all
{}are placed afterif,else,for, etc
They can be omitted for single line ifs without elses
sovdeeth
added
the
enhancement
label
Jan 22, 2026| String newFileName = name + "_" + getBackupSuffix() + ext; | ||
| boolean compress = SkriptConfig.compressBackups.value(); | ||
| if (compress) | ||
| newFileName += ".gz"; |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.zip is more accessible, why pick gz?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are they not both equally accessible?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with fusezion, also gzip is better suited for compression of single files
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mojang uses .gz for the log files
| # 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 |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are the downsides of setting this to true by default?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters