mirror of
https://github.com/immich-app/immich.git
synced 2025-07-09 03:04:16 -04:00
add processing logs
This commit is contained in:
parent
84d665ebad
commit
70263c5351
@ -5,9 +5,6 @@ const double downloadFailed = -2;
|
||||
// Number of log entries to retain on app start
|
||||
const int kLogTruncateLimit = 250;
|
||||
|
||||
// Duration for background sync
|
||||
const Duration kBackgroundSyncDuration = Duration(minutes: 1);
|
||||
|
||||
// Hash batch limits
|
||||
const int kBatchHashFileLimit = 128;
|
||||
const int kBatchHashSizeLimit = 1024 * 1024 * 1024; // 1GB
|
||||
|
@ -63,17 +63,25 @@ class SyncStreamService {
|
||||
}
|
||||
}
|
||||
await _syncApiRepository.ack(acks.values.toList());
|
||||
_logger.info("$types events processed");
|
||||
} catch (error, stack) {
|
||||
_logger.warning("Error handling sync events", error, stack);
|
||||
}
|
||||
streamCompleter.completeOnce();
|
||||
},
|
||||
onError: (_) => streamCompleter.completeOnce(),
|
||||
onError: (error) {
|
||||
_logger.warning("Error in sync stream for $types", error);
|
||||
streamCompleter.completeOnce();
|
||||
},
|
||||
// onDone is required to be called in cases where the stream is empty
|
||||
onDone: () => shouldSkipOnDone ? null : streamCompleter.completeOnce,
|
||||
onDone: () {
|
||||
_logger.info("$types stream done");
|
||||
if (!shouldSkipOnDone) {
|
||||
streamCompleter.completeOnce();
|
||||
}
|
||||
},
|
||||
);
|
||||
streamCompleter.future.whenComplete(subscription.cancel);
|
||||
return await streamCompleter.future;
|
||||
return await streamCompleter.future.whenComplete(subscription.cancel);
|
||||
}
|
||||
|
||||
Future<void> syncUsers() => _syncEvent([SyncRequestType.usersV1]);
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:immich_mobile/constants/constants.dart';
|
||||
import 'package:immich_mobile/utils/background_sync.dart';
|
||||
|
||||
final backgroundSyncProvider = Provider<BackgroundSyncManager>(
|
||||
(ref) => BackgroundSyncManager(duration: kBackgroundSyncDuration),
|
||||
(ref) => BackgroundSyncManager(),
|
||||
);
|
||||
|
@ -5,43 +5,20 @@ import 'dart:async';
|
||||
import 'package:async/async.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/sync_stream.provider.dart';
|
||||
import 'package:immich_mobile/utils/isolate.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
class BackgroundSyncManager {
|
||||
final Logger _logger = Logger('BackgroundSyncManager');
|
||||
Timer? _timer;
|
||||
final Duration _duration;
|
||||
// This allows us to keep synching in the background while allowing ondemand syncs
|
||||
// This prevents multiple syncs from running at the same time
|
||||
final _userSyncCache = AsyncCache.ephemeral();
|
||||
final _partnerSyncCache = AsyncCache.ephemeral();
|
||||
|
||||
BackgroundSyncManager({required Duration duration}) : _duration = duration;
|
||||
|
||||
Timer _createTimer() {
|
||||
return Timer.periodic(_duration, (timer) async {
|
||||
_logger.info('Background sync started');
|
||||
await syncUsers();
|
||||
await syncPartners();
|
||||
_logger.info('Background sync completed');
|
||||
});
|
||||
}
|
||||
|
||||
void start() {
|
||||
_logger.info('Starting Background sync');
|
||||
_timer ??= _createTimer();
|
||||
}
|
||||
|
||||
void stop() {
|
||||
_logger.info('Stopping Background sync');
|
||||
_timer?.cancel();
|
||||
_timer = null;
|
||||
}
|
||||
BackgroundSyncManager();
|
||||
|
||||
Future<void> syncUsers() => _userSyncCache.fetch(
|
||||
() async => runInIsolate(
|
||||
() => runInIsolate(
|
||||
(ref) => ref.read(syncStreamServiceProvider).syncUsers(),
|
||||
),
|
||||
);
|
||||
|
||||
Future<void> syncPartners() => _partnerSyncCache.fetch(
|
||||
() async => runInIsolate(
|
||||
(ref) => ref.read(syncStreamServiceProvider).syncPartners(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user