-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix: timestamp handling for database backup in Web UI #27359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
danieldietzler
merged 4 commits into
immich-app:main
from
AfonsoMendoncaRibeiro:database-backup-consistent-time-handling
Apr 6, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
14f27e9
Fix #26502: Fix timestamp handling for database backup in Web UI
AfonsoMendoncaRibeiro 9004f0e
fix: regenerate open-api types and remove custom backup type
AfonsoMendoncaRibeiro fba74c7
fix: simplify timezone handling for database backups
AfonsoMendoncaRibeiro 5d58429
fix: Add missing newline at end of spec file
AfonsoMendoncaRibeiro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
54 changes: 54 additions & 0 deletions
54
web/src/lib/components/maintenance/MaintenanceBackupEntry.spec.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { locale } from '$lib/stores/preferences.store'; | ||
| import { renderWithTooltips } from '$tests/helpers'; | ||
| import { screen } from '@testing-library/svelte'; | ||
| import { DateTime } from 'luxon'; | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; | ||
| import MaintenanceBackupEntry from './MaintenanceBackupEntry.svelte'; | ||
|
|
||
| vi.mock('$lib/services/database-backups.service', () => ({ | ||
| getDatabaseBackupActions: () => ({ | ||
| Download: { type: 'command', title: 'Download', onAction: vi.fn() }, | ||
| Delete: { type: 'command', title: 'Delete', onAction: vi.fn() }, | ||
| }), | ||
| handleRestoreDatabaseBackup: vi.fn(), | ||
| })); | ||
|
|
||
| describe('MaintenanceBackupEntry', () => { | ||
| beforeEach(() => { | ||
| vi.useFakeTimers(); | ||
| vi.setSystemTime(new Date('2026-03-24T12:00:00Z')); | ||
| locale.set('en'); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| vi.useRealTimers(); | ||
| }); | ||
|
|
||
| it('renders relative backup time using the user timezone instead of UTC', () => { | ||
| const backupTimestamp = '20260324T110000'; | ||
|
|
||
| const expectedRelativeTime = DateTime.fromFormat(backupTimestamp, "yyyyMMdd'T'HHmmss", { | ||
| zone: 'Asia/Tokyo', | ||
| }) | ||
| .toLocal() | ||
| .toRelative({ locale: 'en' }); | ||
|
|
||
| const utcRelativeTime = DateTime.fromFormat(backupTimestamp, "yyyyMMdd'T'HHmmss", { | ||
| zone: 'UTC', | ||
| }) | ||
| .toLocal() | ||
| .toRelative({ locale: 'en' }); | ||
|
|
||
| expect(expectedRelativeTime).toBeTruthy(); | ||
| expect(expectedRelativeTime).not.toEqual(utcRelativeTime); | ||
|
|
||
| renderWithTooltips(MaintenanceBackupEntry, { | ||
| expectedVersion: '1.2.3', | ||
| filename: 'immich-db-backup-20260324T110000-v1.2.3-snapshot.sql.gz', | ||
| filesize: 1024, | ||
| timezone: 'Asia/Tokyo', | ||
| }); | ||
|
|
||
| expect(screen.getByText(expectedRelativeTime!)).toBeInTheDocument(); | ||
| }); | ||
| }); |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this will get the timezone set from the TZ variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, your assumption is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can also add a short comment in the code if you'd like, to make that behavior clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine as is