fix: back-merge v3.1.4 hotfixes into dev (#1371)

Port the three main-only fixes onto dev's (post-rewrite) architecture:
- fix(backups): prevent recursion when the backup path sits inside the backed-up dir
- fix(share): convert budget items to the viewer's base currency instead of a flat EUR
- fix(files): surface the descriptive server error for unsupported upload types (#1363)

Cherry-picked from 819aa793 on main; the SharedTripPage and useTripPlanner
conflicts were resolved to keep dev's font-scaling and full import set while
taking the fixes' currency conversion and translateApiError wiring.
This commit is contained in:
jubnl
2026-07-01 18:57:16 +02:00
committed by Maurice
parent 3686792ce8
commit 60cbd20327
37 changed files with 276 additions and 18 deletions
@@ -475,7 +475,7 @@ describe('BACKUP-036 createBackup', () => {
'**/*',
expect.objectContaining({
cwd: expect.stringContaining('uploads'),
ignore: ['photos/google/**', 'photos/trek/**'],
ignore: ['photos/google/**', 'photos/trek/**', 'backups/**', 'restore-*/**'],
}),
{ prefix: 'uploads' },
);
@@ -483,6 +483,38 @@ describe('BACKUP-036 createBackup', () => {
expect(archiverInstanceMock.directory).not.toHaveBeenCalled();
});
it('BACKUP-036h — never sweeps backups/ or restore-* into the archive (issue #1358)', async () => {
// Regression guard: when data and uploads map to the same directory, the
// uploads glob would otherwise pick up the backups/ dir and recursively
// embed every prior backup zip, compounding size without bound.
fsMock.existsSync.mockImplementation((p: string) => String(p).endsWith('uploads'));
fsMock.mkdirSync.mockReturnValue(undefined);
const writableEvents: Record<string, Function> = {};
const fakeWriteStream = {
on: vi.fn((event: string, cb: Function) => {
writableEvents[event] = cb;
}),
};
fsMock.createWriteStream.mockReturnValue(fakeWriteStream);
archiverInstanceMock.on.mockImplementation((_e: string, _cb: Function) => {});
archiverInstanceMock.pipe.mockReturnValue(undefined);
archiverInstanceMock.finalize.mockImplementation(() => {
if (writableEvents['close']) writableEvents['close']();
});
archiverMock.mockReturnValue(archiverInstanceMock);
fsMock.statSync.mockReturnValue({ size: 1024, birthtime: new Date('2026-04-06T12:00:00Z') });
await createBackup();
const globCall = archiverInstanceMock.glob.mock.calls.at(-1);
const ignore: string[] = globCall?.[1]?.ignore ?? [];
expect(ignore).toContain('backups/**');
expect(ignore).toContain('restore-*/**');
});
it('BACKUP-036f — bundles .encryption_key when present and ENCRYPTION_KEY env is unset', async () => {
const prevEnvKey = process.env.ENCRYPTION_KEY;
delete process.env.ENCRYPTION_KEY;