mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
fix: migrate backup delay from old timeline (#22327)
This commit is contained in:
parent
f7acf1886c
commit
d4b110fc47
4 changed files with 49 additions and 34 deletions
|
|
@ -47,7 +47,7 @@ class BackgroundWorkerApiImpl(context: Context) : BackgroundWorkerFgHostApi {
|
||||||
addContentUriTrigger(MediaStore.Video.Media.INTERNAL_CONTENT_URI, true)
|
addContentUriTrigger(MediaStore.Video.Media.INTERNAL_CONTENT_URI, true)
|
||||||
addContentUriTrigger(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, true)
|
addContentUriTrigger(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, true)
|
||||||
setTriggerContentUpdateDelay(settings.minimumDelaySeconds, TimeUnit.SECONDS)
|
setTriggerContentUpdateDelay(settings.minimumDelaySeconds, TimeUnit.SECONDS)
|
||||||
setTriggerContentMaxDelay(settings.minimumDelaySeconds * 10, TimeUnit.MINUTES)
|
setTriggerContentMaxDelay(settings.minimumDelaySeconds * 10, TimeUnit.SECONDS)
|
||||||
setRequiresCharging(settings.requiresCharging)
|
setRequiresCharging(settings.requiresCharging)
|
||||||
}.build()
|
}.build()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,10 @@ class BackgroundWorkerPreferences(private val ctx: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getSettings(): BackgroundWorkerSettings {
|
fun getSettings(): BackgroundWorkerSettings {
|
||||||
|
val delaySeconds = sp.getLong(SHARED_PREF_MIN_DELAY_KEY, DEFAULT_MIN_DELAY_SECONDS)
|
||||||
|
|
||||||
return BackgroundWorkerSettings(
|
return BackgroundWorkerSettings(
|
||||||
minimumDelaySeconds = sp.getLong(SHARED_PREF_MIN_DELAY_KEY, DEFAULT_MIN_DELAY_SECONDS),
|
minimumDelaySeconds = if (delaySeconds >= 1000) delaySeconds / 1000 else delaySeconds,
|
||||||
requiresCharging = sp.getBoolean(
|
requiresCharging = sp.getBoolean(
|
||||||
SHARED_PREF_REQUIRE_CHARGING_KEY,
|
SHARED_PREF_REQUIRE_CHARGING_KEY,
|
||||||
DEFAULT_REQUIRE_CHARGING
|
DEFAULT_REQUIRE_CHARGING
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import 'package:immich_mobile/providers/infrastructure/db.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/platform.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/platform.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/readonly_mode.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/readonly_mode.provider.dart';
|
||||||
import 'package:immich_mobile/providers/websocket.provider.dart';
|
import 'package:immich_mobile/providers/websocket.provider.dart';
|
||||||
|
import 'package:immich_mobile/services/app_settings.service.dart';
|
||||||
import 'package:immich_mobile/services/background.service.dart';
|
import 'package:immich_mobile/services/background.service.dart';
|
||||||
import 'package:immich_mobile/utils/migration.dart';
|
import 'package:immich_mobile/utils/migration.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
|
|
@ -93,6 +94,10 @@ class _ChangeExperiencePageState extends ConsumerState<ChangeExperiencePage> {
|
||||||
|
|
||||||
await ref.read(driftProvider).reset();
|
await ref.read(driftProvider).reset();
|
||||||
await Store.put(StoreKey.shouldResetSync, true);
|
await Store.put(StoreKey.shouldResetSync, true);
|
||||||
|
final delay = Store.get(StoreKey.backupTriggerDelay, AppSettingsEnum.backupTriggerDelay.defaultValue);
|
||||||
|
if (delay >= 1000) {
|
||||||
|
await Store.put(StoreKey.backupTriggerDelay, (delay / 1000).toInt());
|
||||||
|
}
|
||||||
final permission = await ref.read(galleryPermissionNotifier.notifier).requestGalleryPermission();
|
final permission = await ref.read(galleryPermissionNotifier.notifier).requestGalleryPermission();
|
||||||
|
|
||||||
if (permission.isGranted) {
|
if (permission.isGranted) {
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,14 @@ import 'package:immich_mobile/infrastructure/entities/store.entity.drift.dart';
|
||||||
import 'package:immich_mobile/infrastructure/entities/user.entity.dart';
|
import 'package:immich_mobile/infrastructure/entities/user.entity.dart';
|
||||||
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
||||||
import 'package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart';
|
import 'package:immich_mobile/infrastructure/repositories/sync_stream.repository.dart';
|
||||||
|
import 'package:immich_mobile/services/app_settings.service.dart';
|
||||||
import 'package:immich_mobile/utils/debug_print.dart';
|
import 'package:immich_mobile/utils/debug_print.dart';
|
||||||
import 'package:immich_mobile/utils/diff.dart';
|
import 'package:immich_mobile/utils/diff.dart';
|
||||||
import 'package:isar/isar.dart';
|
import 'package:isar/isar.dart';
|
||||||
// ignore: import_rule_photo_manager
|
// ignore: import_rule_photo_manager
|
||||||
import 'package:photo_manager/photo_manager.dart';
|
import 'package:photo_manager/photo_manager.dart';
|
||||||
|
|
||||||
const int targetVersion = 16;
|
const int targetVersion = 17;
|
||||||
|
|
||||||
Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async {
|
Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async {
|
||||||
final hasVersion = Store.tryGet(StoreKey.version) != null;
|
final hasVersion = Store.tryGet(StoreKey.version) != null;
|
||||||
|
|
@ -64,6 +65,13 @@ Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async {
|
||||||
|
|
||||||
await handleBetaMigration(version, await _isNewInstallation(db, drift), SyncStreamRepository(drift));
|
await handleBetaMigration(version, await _isNewInstallation(db, drift), SyncStreamRepository(drift));
|
||||||
|
|
||||||
|
if (version < 17 && Store.isBetaTimelineEnabled) {
|
||||||
|
final delay = Store.get(StoreKey.backupTriggerDelay, AppSettingsEnum.backupTriggerDelay.defaultValue);
|
||||||
|
if (delay >= 1000) {
|
||||||
|
await Store.put(StoreKey.backupTriggerDelay, (delay / 1000).toInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (targetVersion >= 12) {
|
if (targetVersion >= 12) {
|
||||||
await Store.put(StoreKey.version, targetVersion);
|
await Store.put(StoreKey.version, targetVersion);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue