-
-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
opt.: split webdav & other settings (#569)
- Loading branch information
1 parent
7f0dc65
commit edb49ea
Showing
10 changed files
with
122 additions
and
405 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.