mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
zip backup: add zip archive comment to ease human identification
example comment: data export from Android application nodomain.freeyourgadget.gadgetbridge version 0.86.1 from 2025-08-26T23:59:45Z
This commit is contained in:
+10
@@ -43,6 +43,7 @@ import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
|
||||
public class ZipBackupExportJob extends AbstractZipBackupJob {
|
||||
@@ -243,8 +244,17 @@ public class ZipBackupExportJob extends AbstractZipBackupJob {
|
||||
);
|
||||
final String metadataJson = GSON.toJson(metadata);
|
||||
|
||||
// the comment is deliberately not localized
|
||||
// store the same comment both as zip archive comment and metadata file comment
|
||||
// a few tools show both, some tools only show one and yet other tools show neither
|
||||
final String date = DateTimeUtils.formatIso8601UTC(metadata.getBackupDate());
|
||||
final String comment = "data export from Android application " + metadata.getAppId() + " version " + metadata.getAppVersionName() + " from " + date;
|
||||
|
||||
final ZipEntry zipEntry = new ZipEntry(METADATA_FILENAME);
|
||||
zipEntry.setComment(comment);
|
||||
zipOut.putNextEntry(zipEntry);
|
||||
zipOut.write(metadataJson.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
zipOut.setComment(comment);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user