Add comments to explain why openAndTruncateStream()

This commit is contained in:
Stypox 2024-11-27 16:34:50 +01:00
parent c80c378398
commit 7e4cf82b9d
2 changed files with 5 additions and 0 deletions

View file

@ -76,6 +76,9 @@ public class SubscriptionsExportService extends BaseImportExportService {
try {
outFile = new StoredFileHelper(this, path, "application/json");
// truncate the file before writing to it, otherwise if the new content is smaller than
// the previous file size, the file will retain part of the previous content and be
// corrupted
outputStream = new SharpOutputStream(outFile.openAndTruncateStream());
} catch (final IOException e) {
handleError(e);