mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
feat: GitHub Gist sync (#854)
This commit is contained in:
@@ -12,12 +12,28 @@ final class BakSyncer extends SyncIface {
|
||||
const BakSyncer._() : super();
|
||||
|
||||
@override
|
||||
Future<void> saveToFile() => BackupV2.backup();
|
||||
Future<void> saveToFile() async {
|
||||
final pwd = await SecureStoreProps.bakPwd.read();
|
||||
if (pwd == null || pwd.isEmpty) {
|
||||
// Enforce password for non-clipboard backups
|
||||
throw Exception('Backup password not set');
|
||||
}
|
||||
await BackupV2.backup(null, pwd);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Mergeable> fromFile(String path) async {
|
||||
final content = await File(path).readAsString();
|
||||
return MergeableUtils.fromJsonString(content).$1;
|
||||
final pwd = await SecureStoreProps.bakPwd.read();
|
||||
try {
|
||||
if (Cryptor.isEncrypted(content)) {
|
||||
return MergeableUtils.fromJsonString(content, pwd).$1;
|
||||
}
|
||||
return MergeableUtils.fromJsonString(content).$1;
|
||||
} catch (_) {
|
||||
// Fallback: try without password if detection failed
|
||||
return MergeableUtils.fromJsonString(content).$1;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -28,6 +44,9 @@ final class BakSyncer extends SyncIface {
|
||||
final webdavEnabled = PrefProps.webdavSync.get();
|
||||
if (webdavEnabled) return Webdav.shared;
|
||||
|
||||
final gistEnabled = PrefProps.gistSync.get();
|
||||
if (gistEnabled) return GistRs.shared;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user