Queue encryption and decryption with work-manager

This commit is contained in:
Vishnu Mohandas 2020-08-14 03:31:18 +05:30
parent 38b2c76892
commit 5000a0b3cd
4 changed files with 16 additions and 5 deletions

View file

@ -12,6 +12,7 @@ import 'package:photos/ui/home_widget.dart';
import 'package:sentry/sentry.dart';
import 'package:super_logging/super_logging.dart';
import 'package:logging/logging.dart';
import 'package:worker_manager/worker_manager.dart';
final logger = Logger("main");
@ -25,6 +26,7 @@ void main() async {
}
void _main() async {
await Executor().warmUp();
await Configuration.instance.init();
await PhotoSyncManager.instance.init();
await MemoriesService.instance.init();

View file

@ -4,7 +4,7 @@ import 'package:aes_crypt/aes_crypt.dart';
import 'package:encrypt/encrypt.dart';
import 'dart:convert';
import 'package:flutter/foundation.dart' as foundation;
import 'package:worker_manager/worker_manager.dart';
class CryptoUtil {
static String getBase64EncodedSecureRandomString({int length = 32}) {
@ -39,7 +39,8 @@ class CryptoUtil {
args["key"] = key;
args["source"] = sourcePath;
args["destination"] = destinationPath;
return foundation.compute(runEncryptFileToFile, args);
return Executor().execute(arg1: args, fun1: runEncryptFileToFile);
}
static Future<String> encryptDataToFile(
@ -48,7 +49,7 @@ class CryptoUtil {
args["key"] = key;
args["source"] = source;
args["destination"] = destinationPath;
return foundation.compute(runEncryptDataToFile, args);
return Executor().execute(arg1: args, fun1: runEncryptDataToFile);
}
static Future<void> decryptFileToFile(
@ -57,14 +58,14 @@ class CryptoUtil {
args["key"] = key;
args["source"] = sourcePath;
args["destination"] = destinationPath;
return foundation.compute(runDecryptFileToFile, args);
return Executor().execute(arg1: args, fun1: runDecryptFileToFile);
}
static Future<Uint8List> decryptFileToData(String sourcePath, String key) {
final args = Map<String, String>();
args["key"] = key;
args["source"] = sourcePath;
return foundation.compute(runDecryptFileToData, args);
return Executor().execute(arg1: args, fun1: runDecryptFileToData);
}
}

View file

@ -700,6 +700,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4+2"
worker_manager:
dependency: "direct main"
description:
name: worker_manager
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
xdg_directories:
dependency: transitive
description:

View file

@ -58,6 +58,7 @@ dependencies:
progress_dialog: ^1.2.4
animate_do: ^1.7.2
flutter_cache_manager: ^1.4.1
worker_manager: ^3.0.0
dev_dependencies:
flutter_test: