fixes before build 2

This commit is contained in:
gitea
2026-08-31 17:05:22 +02:00
parent 14fcb9a533
commit b0708101b0
20 changed files with 72 additions and 61 deletions
+7 -3
View File
@@ -5,6 +5,9 @@ import 'dart:convert';
const int kBackupVersion = 3;
const String kBackupFormat = 'groci-backup';
const String kLegacyBackupFormat = 'receipity-backup';
class BackupDocument {
const BackupDocument({
required this.version,
@@ -33,7 +36,7 @@ class BackupDocument {
final Map<String, String> images;
Map<String, Object?> toJson() => {
'format': 'receipity-backup',
'format': kBackupFormat,
'version': version,
'exportedAt': exportedAt,
'darkMode': darkMode,
@@ -54,8 +57,9 @@ class BackupDocument {
if (decoded is! Map<String, dynamic>) {
throw const FormatException('Backup is not a JSON object.');
}
if (decoded['format'] != 'receipity-backup') {
throw const FormatException('This file is not a Receipity backup.');
final format = decoded['format'];
if (format != kBackupFormat && format != kLegacyBackupFormat) {
throw const FormatException('This file is not a Groci backup.');
}
final version = decoded['version'];
if (version is! int || version < 1 || version > kBackupVersion) {