Skip to content

Commit

Permalink
opt.: split webdav & other settings (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
lollipopkit authored Aug 31, 2024
1 parent 7f0dc65 commit edb49ea
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 405 deletions.
40 changes: 40 additions & 0 deletions lib/core/sync.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'dart:io';

import 'package:fl_lib/fl_lib.dart';
import 'package:server_box/data/model/app/backup.dart';
import 'package:server_box/data/store/no_backup.dart';

const sync = Sync._();

final class Sync extends SyncCfg {
const Sync._() : super();

@override
Future<void> saveToFile() => Backup.backup();

@override
Future<Mergeable> fromFile(String path) async {
final content = await File(path).readAsString();
return Backup.fromJsonString(content);
}

@override
Future<RemoteStorage?> get remoteStorage async {
if (isMacOS || isIOS) await icloud.init('iCloud.tech.lolli.serverbox');
final settings = NoBackupStore.instance;
await webdav.init(WebdavInitArgs(
url: settings.webdavUrl.fetch(),
user: settings.webdavUser.fetch(),
pwd: settings.webdavPwd.fetch(),
prefix: 'serverbox/',
));

final icloudEnabled = settings.icloudSync.fetch();
if (icloudEnabled) return icloud;

final webdavEnabled = settings.webdavSync.fetch();
if (webdavEnabled) return webdav;

return null;
}
}
224 changes: 0 additions & 224 deletions lib/core/utils/sync/icloud.dart

This file was deleted.

127 changes: 0 additions & 127 deletions lib/core/utils/sync/webdav.dart

This file was deleted.

Loading

0 comments on commit edb49ea

Please sign in to comment.