mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feat: delta sync (#18428)
* feat: delta sync * fix: ignore iCloud assets * feat: dev logs * add full sync button * remove photo_manager dep for sync * misc logs and fix * add time taken to DLog * fix: build release iOS * ios sync go brrr * rename local sync service * update isar fork * rename to platform assets / albums * fix ci check --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
parent
2b1b20ab0b
commit
dbdb64f6c5
49 changed files with 5634 additions and 488 deletions
68
mobile/lib/presentation/pages/dev/dev_logger.dart
Normal file
68
mobile/lib/presentation/pages/dev/dev_logger.dart
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:immich_mobile/domain/models/log.model.dart';
|
||||
import 'package:immich_mobile/infrastructure/entities/log.entity.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/log.repository.dart';
|
||||
// ignore: import_rule_isar
|
||||
import 'package:isar/isar.dart';
|
||||
|
||||
const kDevLoggerTag = 'DEV';
|
||||
|
||||
abstract final class DLog {
|
||||
const DLog();
|
||||
|
||||
static Stream<List<LogMessage>> watchLog() {
|
||||
final db = Isar.getInstance();
|
||||
if (db == null) {
|
||||
debugPrint('Isar is not initialized');
|
||||
return const Stream.empty();
|
||||
}
|
||||
|
||||
return db.loggerMessages
|
||||
.filter()
|
||||
.context1EqualTo(kDevLoggerTag)
|
||||
.sortByCreatedAtDesc()
|
||||
.watch(fireImmediately: true)
|
||||
.map((logs) => logs.map((log) => log.toDto()).toList());
|
||||
}
|
||||
|
||||
static void clearLog() {
|
||||
final db = Isar.getInstance();
|
||||
if (db == null) {
|
||||
debugPrint('Isar is not initialized');
|
||||
return;
|
||||
}
|
||||
|
||||
db.writeTxnSync(() {
|
||||
db.loggerMessages.filter().context1EqualTo(kDevLoggerTag).deleteAllSync();
|
||||
});
|
||||
}
|
||||
|
||||
static void log(String message, [Object? error, StackTrace? stackTrace]) {
|
||||
debugPrint('[$kDevLoggerTag] [${DateTime.now()}] $message');
|
||||
if (error != null) {
|
||||
debugPrint('Error: $error');
|
||||
}
|
||||
if (stackTrace != null) {
|
||||
debugPrint('StackTrace: $stackTrace');
|
||||
}
|
||||
|
||||
final isar = Isar.getInstance();
|
||||
if (isar == null) {
|
||||
debugPrint('Isar is not initialized');
|
||||
return;
|
||||
}
|
||||
|
||||
final record = LogMessage(
|
||||
message: message,
|
||||
level: LogLevel.info,
|
||||
createdAt: DateTime.now(),
|
||||
logger: kDevLoggerTag,
|
||||
error: error?.toString(),
|
||||
stack: stackTrace?.toString(),
|
||||
);
|
||||
|
||||
unawaited(IsarLogRepository(isar).insert(record));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue