Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 42 additions & 17 deletions flutter/lib/models/file_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -391,14 +391,30 @@ class FileController {

await Future.delayed(Duration(milliseconds: 100));

final dir = (await bind.sessionGetPeerOption(
final savedDir = (await bind.sessionGetPeerOption(
sessionId: sessionId, name: isLocal ? "local_dir" : "remote_dir"));
openDirectory(dir.isEmpty ? options.value.home : dir);
Future<bool> tryOpenReadyDirs() async {
final dirs = <String>{
if (directory.value.path.isNotEmpty) directory.value.path,
if (savedDir.isNotEmpty) savedDir,
options.value.home,
};
for (final dir in dirs) {
if (await _openDirectoryPath(dir, isBack: true)) {
return true;
}
}
return false;
}

var opened = await tryOpenReadyDirs();

await Future.delayed(Duration(seconds: 1));

if (directory.value.path.isEmpty) {
openDirectory(options.value.home);
if (!opened) {
// The peer may become ready during the reconnect delay, so retry the
// same candidates instead of only retrying the default home directory.
await tryOpenReadyDirs();
}
}

Expand Down Expand Up @@ -429,19 +445,23 @@ class FileController {
});
}

Future<void> refresh() async {
await openDirectory(directory.value.path);
Future<bool> refresh() async {
// "." can be both a refresh command and a real remote directory path.
// Refresh must bypass openDirectory's command dispatch to avoid recursion.
return await _openDirectoryPath(directory.value.path, isBack: true);
}

Future<void> openDirectory(String path, {bool isBack = false}) async {
if (path == ".") {
refresh();
return;
Future<bool> openDirectory(String path, {bool isBack = false}) async {
if (!isBack && path == ".") {
return await refresh();
}
if (path == "..") {
goToParentDirectory();
return;
if (!isBack && path == "..") {
return await _goToParentDirectory(isBack: isBack);
}
return await _openDirectoryPath(path, isBack: isBack);
}

Future<bool> _openDirectoryPath(String path, {bool isBack = false}) async {
if (!isBack) {
pushHistory();
}
Expand All @@ -458,8 +478,10 @@ class FileController {
final fd = await fileFetcher.fetchDirectory(path, isLocal, showHidden);
fd.format(isWindows, sort: sortBy.value);
directory.value = fd;
return true;
} catch (e) {
debugPrint("Failed to openDirectory $path: $e");
return false;
}
}

Expand Down Expand Up @@ -487,19 +509,22 @@ class FileController {
goBack();
return;
}
openDirectory(path, isBack: true);
unawaited(_openDirectoryPath(path, isBack: true).then<void>((_) {}));
}

void goToParentDirectory() {
unawaited(_goToParentDirectory().then<void>((_) {}));
}

Future<bool> _goToParentDirectory({bool isBack = false}) async {
final isWindows = options.value.isWindows;
final dirPath = directory.value.path;
var parent = PathUtil.dirname(dirPath, isWindows);
// specially for C:\, D:\, goto '/'
if (parent == dirPath && isWindows) {
openDirectory('/');
return;
return await _openDirectoryPath('/', isBack: isBack);
}
openDirectory(parent);
return await _openDirectoryPath(parent, isBack: isBack);
}

// TODO deprecated this
Expand Down
2 changes: 1 addition & 1 deletion src/lang/ja.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Changelog", "更新履歴"),
("keep-awake-during-outgoing-sessions-label", "送信セッション中は、画面のスリープを無効化する"),
("keep-awake-during-incoming-sessions-label", "受信セッション中は、画面のスリープを無効化する"),
("Continue with {}", "{}で続行する"),
("Continue with {}", "{} で続行する"),
("Display Name", "表示名"),
("password-hidden-tip", "永続的なパスワードが設定されています (非表示)"),
("preset-password-in-use-tip", "プリセットパスワードが現在使用されています"),
Expand Down
Loading