From a60ad1e980b66fd3b718b35a1ab17b7fc81e57ef Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Tue, 25 May 2021 14:59:00 +0800 Subject: [PATCH] Fix token path for root dir --- lib/touch_token_manager.dart | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/touch_token_manager.dart b/lib/touch_token_manager.dart index 3f078c2f..0560de31 100644 --- a/lib/touch_token_manager.dart +++ b/lib/touch_token_manager.dart @@ -67,11 +67,23 @@ class TouchTokenManager { return platform.UniversalStorage().getString(name); } - String _getRemotePath(Account account, File file) => - "${remote_storage_util.getRemoteTouchDir(account)}/${file.strippedPath}/token.txt"; + String _getRemotePath(Account account, File file) { + final strippedPath = file.strippedPath; + if (strippedPath == ".") { + return "${remote_storage_util.getRemoteTouchDir(account)}/token.txt"; + } else { + return "${remote_storage_util.getRemoteTouchDir(account)}/${file.strippedPath}/token.txt"; + } + } - String _getLocalStorageName(Account account, File file) => - "touch/${account.url.replaceFirst('://', '_')}/${file.strippedPath}/token"; + String _getLocalStorageName(Account account, File file) { + final strippedPath = file.strippedPath; + if (strippedPath == ".") { + return "touch/${account.url.replaceFirst('://', '_')}/token"; + } else { + return "touch/${account.url.replaceFirst('://', '_')}/${file.strippedPath}/token"; + } + } static final _log = Logger("touch_token_manager.TouchTokenManager"); }