fixes before build 2
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user