mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
opt.: migrate fl_lib
This commit is contained in:
@@ -2,13 +2,13 @@ import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:computer/computer.dart';
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:icloud_storage/icloud_storage.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:toolbox/data/model/app/backup.dart';
|
||||
import 'package:toolbox/data/model/app/sync.dart';
|
||||
|
||||
import '../../../data/model/app/error.dart';
|
||||
import '../../../data/res/path.dart';
|
||||
|
||||
abstract final class ICloud {
|
||||
static const _containerId = 'iCloud.tech.lolli.serverbox';
|
||||
@@ -31,7 +31,7 @@ abstract final class ICloud {
|
||||
try {
|
||||
await ICloudStorage.upload(
|
||||
containerId: _containerId,
|
||||
filePath: localPath ?? '${await Paths.doc}/$relativePath',
|
||||
filePath: localPath ?? '${Paths.doc}/$relativePath',
|
||||
destinationRelativePath: relativePath,
|
||||
onProgress: (stream) {
|
||||
stream.listen(
|
||||
@@ -85,7 +85,7 @@ abstract final class ICloud {
|
||||
await ICloudStorage.download(
|
||||
containerId: _containerId,
|
||||
relativePath: relativePath,
|
||||
destinationFilePath: localPath ?? '${await Paths.doc}/$relativePath',
|
||||
destinationFilePath: localPath ?? '${Paths.doc}/$relativePath',
|
||||
onProgress: (stream) {
|
||||
stream.listen(
|
||||
null,
|
||||
@@ -139,7 +139,7 @@ abstract final class ICloud {
|
||||
}
|
||||
}));
|
||||
|
||||
final docPath = await Paths.doc;
|
||||
final docPath = Paths.doc;
|
||||
|
||||
/// compare files in iCloud and local
|
||||
missions.addAll(allFiles.map((file) async {
|
||||
@@ -205,7 +205,7 @@ abstract final class ICloud {
|
||||
return;
|
||||
}
|
||||
|
||||
final dlFile = await File(await Paths.bak).readAsString();
|
||||
final dlFile = await File(Paths.bakPath).readAsString();
|
||||
final dlBak = await Computer.shared.start(Backup.fromJsonString, dlFile);
|
||||
await dlBak.restore();
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:computer/computer.dart';
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:toolbox/data/model/app/backup.dart';
|
||||
import 'package:toolbox/data/model/app/error.dart';
|
||||
import 'package:toolbox/data/res/path.dart';
|
||||
import 'package:toolbox/data/res/store.dart';
|
||||
import 'package:webdav_client/webdav_client.dart';
|
||||
|
||||
@@ -37,7 +37,7 @@ abstract final class Webdav {
|
||||
}) async {
|
||||
try {
|
||||
await _client.writeFile(
|
||||
localPath ?? '${await Paths.doc}/$relativePath',
|
||||
localPath ?? '${Paths.doc}/$relativePath',
|
||||
_prefix + relativePath,
|
||||
);
|
||||
} catch (e, s) {
|
||||
@@ -64,7 +64,7 @@ abstract final class Webdav {
|
||||
try {
|
||||
await _client.readFile(
|
||||
_prefix + relativePath,
|
||||
localPath ?? '${await Paths.doc}/$relativePath',
|
||||
localPath ?? '${Paths.doc}/$relativePath',
|
||||
);
|
||||
} catch (e) {
|
||||
_logger.warning('Download $relativePath failed');
|
||||
@@ -104,7 +104,7 @@ abstract final class Webdav {
|
||||
}
|
||||
|
||||
try {
|
||||
final dlFile = await File(await Paths.bak).readAsString();
|
||||
final dlFile = await File(Paths.bakPath).readAsString();
|
||||
final dlBak = await Computer.shared.start(Backup.fromJsonString, dlFile);
|
||||
await dlBak.restore();
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user