feat(mobile): hash assets in isolate (#18924)

This commit is contained in:
shenlong 2025-06-06 11:23:05 +05:30 committed by GitHub
parent b46e066cc2
commit ce6631f7e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 1254 additions and 428 deletions

View file

@ -7,6 +7,7 @@ import 'package:worker_manager/worker_manager.dart';
class BackgroundSyncManager {
Cancelable<void>? _syncTask;
Cancelable<void>? _deviceAlbumSyncTask;
Cancelable<void>? _hashTask;
BackgroundSyncManager();
@ -45,6 +46,20 @@ class BackgroundSyncManager {
});
}
// No need to cancel the task, as it can also be run when the user logs out
Future<void> hashAssets() {
if (_hashTask != null) {
return _hashTask!.future;
}
_hashTask = runInIsolateGentle(
computation: (ref) => ref.read(hashServiceProvider).hashAssets(),
);
return _hashTask!.whenComplete(() {
_hashTask = null;
});
}
Future<void> syncRemote() {
if (_syncTask != null) {
return _syncTask!.future;