qt wizard: fix wallets directory relative paths on Windows
follow-up https://github.com/spesmilo/electrum/pull/8651 We cannot do direct comparison of path-like strings without normalisation. E.g. ``` relative_path() cp1. path='c:\\users\\user\\appdata\\roaming\\electrum\\wallets\\9dk', wallets=C:\Users\User\AppData\Roaming\Electrum\wallets relative_path() cp2. commonpath='c:\\users\\user\\appdata\\roaming\\electrum\\wallets' relative_path() cp3. new_path='9dk' ```
This commit is contained in:
@@ -16,6 +16,7 @@ from electrum.keystore import bip44_derivation, bip39_to_seed, purpose48_derivat
|
||||
from electrum.plugin import run_hook, HardwarePluginLibraryUnavailable
|
||||
from electrum.storage import StorageReadWriteError
|
||||
from electrum.util import WalletFileException, get_new_wallet_name, UserFacingException, InvalidPassword
|
||||
from electrum.util import is_subpath
|
||||
from electrum.wallet import wallet_types
|
||||
from .wizard import QEAbstractWizard, WizardComponent
|
||||
from electrum.logging import get_logger, Logger
|
||||
@@ -303,9 +304,9 @@ class WCWalletName(WizardComponent, Logger):
|
||||
def relative_path(path):
|
||||
new_path = path
|
||||
try:
|
||||
commonpath = os.path.commonpath([path, datadir_wallet_folder])
|
||||
if commonpath == datadir_wallet_folder:
|
||||
if is_subpath(path, datadir_wallet_folder):
|
||||
# below datadir_wallet_path, make relative
|
||||
commonpath = os.path.commonpath([path, datadir_wallet_folder])
|
||||
new_path = os.path.relpath(path, commonpath)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user