new: webdav sync test
This commit is contained in:
@@ -43,7 +43,6 @@ class PersistentStore {
|
||||
//encryptionCipher: SecureStore._cipher,
|
||||
);
|
||||
|
||||
|
||||
/// Get all db filenames.
|
||||
///
|
||||
/// - [suffixs] defaults to ['.hive']
|
||||
@@ -69,7 +68,6 @@ class PersistentStore {
|
||||
files.map((e) => e.path.replaceFirst('$docPath/', '')).toList();
|
||||
return paths;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension BoxX on Box {
|
||||
|
||||
@@ -16,6 +16,17 @@ abstract final class Webdav {
|
||||
pwd: Stores.setting.webdavPwd.fetch(),
|
||||
);
|
||||
|
||||
static Future<String?> test(String url, String user, String pwd) async {
|
||||
final client = WebdavClient(url: url, user: user, pwd: pwd);
|
||||
try {
|
||||
await client.ping();
|
||||
return null;
|
||||
} catch (e, s) {
|
||||
Loggers.app.warning('Webdav test failed', e, s);
|
||||
return e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static Future<WebdavErr?> upload({
|
||||
required String relativePath,
|
||||
String? localPath,
|
||||
|
||||
@@ -6,7 +6,8 @@ enum ErrFrom {
|
||||
ssh,
|
||||
status,
|
||||
icloud,
|
||||
webdav,;
|
||||
webdav,
|
||||
;
|
||||
}
|
||||
|
||||
abstract class Err<T> {
|
||||
@@ -73,7 +74,8 @@ class ICloudErr extends Err<ICloudErrType> {
|
||||
|
||||
enum WebdavErrType {
|
||||
generic,
|
||||
notFound,;
|
||||
notFound,
|
||||
;
|
||||
}
|
||||
|
||||
class WebdavErr extends Err<WebdavErrType> {
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
abstract class RemoteStorage {
|
||||
Future<Error> upload({
|
||||
required String relativePath,
|
||||
String? localPath
|
||||
});
|
||||
|
||||
Future<Error> download({
|
||||
required String relativePath,
|
||||
String? localPath
|
||||
});
|
||||
|
||||
Future<Error> delete(String relativePath);
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 654;
|
||||
static const int build = 660;
|
||||
static const String engine = "3.16.2";
|
||||
static const String buildAt = "2023-12-02 00:21:29";
|
||||
static const int modifications = 2;
|
||||
static const String buildAt = "2023-12-04 13:43:20";
|
||||
static const int modifications = 11;
|
||||
static const int script = 31;
|
||||
}
|
||||
|
||||
@@ -218,6 +218,7 @@
|
||||
"tag": "Tags",
|
||||
"temperature": "Temperatur",
|
||||
"terminal": "Terminal",
|
||||
"test": "Prüfung",
|
||||
"theme": "Themen",
|
||||
"themeMode": "Themen-Modus",
|
||||
"times": "x",
|
||||
|
||||
@@ -218,6 +218,7 @@
|
||||
"tag": "Tags",
|
||||
"temperature": "Temperature",
|
||||
"terminal": "Terminal",
|
||||
"test": "Test",
|
||||
"theme": "Theme",
|
||||
"themeMode": "Theme mode",
|
||||
"times": "Times",
|
||||
|
||||
@@ -218,6 +218,7 @@
|
||||
"tag": "Tag",
|
||||
"temperature": "Suhu",
|
||||
"terminal": "Terminal",
|
||||
"test": "pengujian",
|
||||
"theme": " Tema",
|
||||
"themeMode": "Mode tema",
|
||||
"times": "Waktu",
|
||||
|
||||
@@ -218,6 +218,7 @@
|
||||
"tag": "标签",
|
||||
"temperature": "温度",
|
||||
"terminal": "终端",
|
||||
"test": "测试",
|
||||
"theme": "主题",
|
||||
"themeMode": "主题模式",
|
||||
"times": "次",
|
||||
|
||||
@@ -218,6 +218,7 @@
|
||||
"tag": "标签",
|
||||
"temperature": "溫度",
|
||||
"terminal": "终端機",
|
||||
"test": "測試",
|
||||
"theme": "主題",
|
||||
"themeMode": "主題模式",
|
||||
"times": "次",
|
||||
|
||||
@@ -119,9 +119,8 @@ class BackupPage extends StatelessWidget {
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await backup.restore(force: true);
|
||||
Pros.reload();
|
||||
context.pop();
|
||||
RebuildNodes.app.rebuild();
|
||||
_reload();
|
||||
},
|
||||
child: Text(l10n.ok),
|
||||
),
|
||||
@@ -156,6 +155,7 @@ class BackupPage extends StatelessWidget {
|
||||
icloudLoading.value = true;
|
||||
await ICloud.sync();
|
||||
icloudLoading.value = false;
|
||||
_reload();
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -195,6 +195,7 @@ class BackupPage extends StatelessWidget {
|
||||
await compute(Backup.fromJsonString, dlFile);
|
||||
await dlBak.restore(force: true);
|
||||
icloudLoading.value = false;
|
||||
_reload();
|
||||
},
|
||||
child: Text(l10n.download),
|
||||
),
|
||||
@@ -251,7 +252,8 @@ class BackupPage extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Input(
|
||||
label: 'url',
|
||||
label: 'URL',
|
||||
hint: 'https://example.com/webdav/',
|
||||
controller: urlCtrl,
|
||||
),
|
||||
Input(
|
||||
@@ -271,6 +273,21 @@ class BackupPage extends StatelessWidget {
|
||||
},
|
||||
child: Text(l10n.ok),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
final result = await Webdav.test(
|
||||
urlCtrl.text,
|
||||
userCtrl.text,
|
||||
pwdCtrl.text,
|
||||
);
|
||||
if (result == null) {
|
||||
context.showSnackBar(l10n.success);
|
||||
} else {
|
||||
context.showSnackBar(result);
|
||||
}
|
||||
},
|
||||
child: Text(l10n.test),
|
||||
),
|
||||
],
|
||||
);
|
||||
if (result == true) {
|
||||
@@ -294,6 +311,7 @@ class BackupPage extends StatelessWidget {
|
||||
webdavLoading.value = true;
|
||||
await Webdav.sync();
|
||||
webdavLoading.value = false;
|
||||
_reload();
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -334,6 +352,7 @@ class BackupPage extends StatelessWidget {
|
||||
await compute(Backup.fromJsonString, dlFile);
|
||||
await dlBak.restore(force: true);
|
||||
webdavLoading.value = false;
|
||||
_reload();
|
||||
},
|
||||
child: Text(l10n.download),
|
||||
),
|
||||
@@ -363,4 +382,9 @@ class BackupPage extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _reload() {
|
||||
Pros.reload();
|
||||
RebuildNodes.app.rebuild();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:code_text_field/code_text_field.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_highlight/theme_map.dart';
|
||||
import 'package:flutter_highlight/themes/a11y-light.dart';
|
||||
@@ -64,15 +65,25 @@ class _EditorPageState extends State<EditorPage> {
|
||||
language: Highlights.all[_langCode],
|
||||
);
|
||||
|
||||
/// TODO: This is a temporary solution to avoid the loading stuck
|
||||
Future.delayed(const Duration(milliseconds: 377)).then((value) async {
|
||||
if (widget.path != null) {
|
||||
final code = await File(widget.path!).readAsString();
|
||||
_controller.text = code;
|
||||
} else if (widget.text != null) {
|
||||
_controller.text = widget.text!;
|
||||
}
|
||||
});
|
||||
if (_langCode == null) {
|
||||
_setupCtrl();
|
||||
} else {
|
||||
Future.delayed(const Duration(milliseconds: 377)).then(
|
||||
(value) async => await _setupCtrl(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _setupCtrl() async {
|
||||
if (widget.path != null) {
|
||||
final code = await compute(
|
||||
(path) async => await File(path).readAsString(),
|
||||
widget.path!,
|
||||
);
|
||||
_controller.text = code;
|
||||
} else if (widget.text != null) {
|
||||
_controller.text = widget.text!;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user