new: manual icloud sync

This commit is contained in:
lollipopkit
2023-09-12 14:02:31 +08:00
parent 700322c603
commit 9ce7138d9b
5 changed files with 28 additions and 19 deletions

View File

@@ -7,6 +7,7 @@ import 'package:logging/logging.dart';
import '../../data/model/app/error.dart';
import '../../data/model/app/json.dart';
import '../../data/res/path.dart';
import 'platform.dart';
final _logger = Logger('iCloud');
@@ -173,3 +174,14 @@ class ICloud {
}
}
}
Future<void> syncApple() async {
if (!isIOS && !isMacOS) return;
final docPath = await docDir;
final dir = Directory(docPath);
final files = await dir.list().toList();
// filter out non-hive(db) files
files.removeWhere((e) => !e.path.endsWith('.hive'));
final paths = files.map((e) => e.path.replaceFirst('$docPath/', ''));
await ICloud.sync(relativePaths: paths);
}