Repository navigation
Use local time for the local backup folder name - #15039
Open
Andrea-Bruno wants to merge 1 commit into
Open
Andrea-Bruno wants to merge 1 commit into
Andrea-Bruno wants to merge 1 commit into
Conversation
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.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.