Skip to content

Use local time for the local backup folder name - #15039

Open
Andrea-Bruno wants to merge 1 commit into
signalapp:mainfrom
Andrea-Bruno:fix/backup-folder-local-time
Open

Andrea-Bruno wants to merge 1 commit into
signalapp:mainfrom
Andrea-Bruno:fix/backup-folder-local-time

Conversation

@Andrea-Bruno

Copy link
Copy Markdown

This fixes #14866.

The new folder-based backup names its snapshot folder with a UTC timestamp. The old file-based backup used the local time on the device. Because of this the folder name does not match the time the user sees on their phone, which is confusing. A user in a UTC+2 zone reported that at local time 07:38:26 the folder was named signal-backup-2026-07-07-05-38-26.

I confirmed this by reading the code. In ArchiveFileSystem.createSnapshot() the timestamp is built with a SimpleDateFormat that is forced to UTC with .apply { timeZone = TimeZone.getTimeZone("UTC") }. The older backup jobs (LocalBackupJob and LocalBackupJobApi29) build the same timestamp with no time zone override, so they use the device local time. That is the whole difference between the two formats.

The fix makes the folder name use the device local time, to match the old format and what the user expects.

This change touches two places on purpose, and I want to explain why. The folder name is not only written, it is also read back. The function toMilliseconds() parses the timestamp out of the folder name, and listSnapshots() uses that value to sort the backups newest first and to match the backup the user selects. The parser was also hardcoded to UTC. If I changed only the writer to local time and left the parser on UTC, the value read back would no longer match the real time, and the order of the list could be wrong when a device has both an old folder and a new folder near a daylight saving change. So I changed the writer and the parser together to use the same local time. That keeps them consistent for every backup made by this code.

I checked the existing tests for this class. They cover the restore directory structure and do not assert anything about the time zone, so they still pass. I also compiled the app module and it builds.

One small thing to note. A device that already has a folder made by the old UTC code and then makes a new folder with this local-time code could show those two folders in a slightly wrong order only if they are very close to a daylight saving change. This is a short lived case because old backups are pruned and only the two most recent are kept.

The folder-based backup named its snapshot folder in UTC, while the old file-based backup used local time. This made the folder name confusing because it did not match the time shown on the device. Use the device local time for both the folder name and the parser that reads it back, so the two stay consistent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backup timestamp in UTC

1 participant