Skip to content

Commit

Permalink
Remove configs from backup
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-Stackflow committed Aug 23, 2024
1 parent be22a65 commit 34698f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 33 deletions.
38 changes: 10 additions & 28 deletions lib/TokenUtils/Backup/backup.dart
Original file line number Diff line number Diff line change
@@ -1,54 +1,36 @@
import 'dart:convert';

import 'package:cloudotp/Models/cloud_service_config.dart';

import '../../Models/token_category.dart';
import '../../Models/config.dart';
import '../../Models/opt_token.dart';
import '../../Models/token_category.dart';

class Backup {
final List<OtpToken> tokens;
final List<TokenCategory> categories;
final Config config;
final List<CloudServiceConfig> cloudServiceConfigs;

String get json => jsonEncode(toJson());

Backup({
required this.tokens,
required this.categories,
required this.cloudServiceConfigs,
required this.config,
});

Map<String, dynamic> toJson() {
return {
'tokens': tokens.map((e) => e.toJson()).toList(),
'categories': categories.map((e) => e.toJson()).toList(),
'cloudServiceConfigs':
cloudServiceConfigs.map((e) => e.toJson()).toList(),
'config': config.toJson(),
};
}

static Backup fromJson(Map<String, dynamic> json) {
return Backup(
tokens: json['tokens'] != null
? (json['tokens'] as List).map((e) => OtpToken.fromJson(e)).toList()
: [],
categories: json['categories'] != null
? (json['categories'] as List)
.map((e) => TokenCategory.fromJson(e))
.toList()
: [],
cloudServiceConfigs: json['cloudServiceConfigs'] != null
? (json['cloudServiceConfigs'] as List)
.map((e) => CloudServiceConfig.fromJson(e))
.toList()
: [],
config: json['config'] != null
? Config.fromJson(json['config'])
: Config());
tokens: json['tokens'] != null
? (json['tokens'] as List).map((e) => OtpToken.fromJson(e)).toList()
: [],
categories: json['categories'] != null
? (json['categories'] as List)
.map((e) => TokenCategory.fromJson(e))
.toList()
: [],
);
}

}
5 changes: 0 additions & 5 deletions lib/TokenUtils/export_token_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,10 @@ class ExportTokenUtil {
String tmpPassword = password ?? await ConfigDao.getBackupPassword();
List<OtpToken> tokens = await TokenDao.listTokens();
List<TokenCategory> categories = await CategoryDao.listCategories();
Config config = await ConfigDao.getConfig();
List<CloudServiceConfig> cloudServiceConfigs =
await CloudServiceConfigDao.getConfigs();
return await compute((_) async {
Backup backup = Backup(
tokens: tokens,
categories: categories,
config: config,
cloudServiceConfigs: cloudServiceConfigs,
);
BackupEncryptionV1 backupEncryption = BackupEncryptionV1();
Uint8List encryptedData =
Expand Down

0 comments on commit 34698f2

Please sign in to comment.