Fix StorageManager.get_local_copy() returning None for a valid path in Windows

This commit is contained in:
allegroai 2022-04-13 14:34:01 +03:00
parent 0c0739379b
commit 6330c879f8
2 changed files with 7 additions and 0 deletions

View File

@ -51,6 +51,10 @@ class CacheManager(object):
): ):
# type: (str, bool, bool) -> Optional[str] # type: (str, bool, bool) -> Optional[str]
helper = StorageHelper.get(remote_url) helper = StorageHelper.get(remote_url)
if helper.base_url == "file://":
remote_url = os.path.expanduser(remote_url)
if not helper: if not helper:
raise ValueError("Storage access failed: {}".format(remote_url)) raise ValueError("Storage access failed: {}".format(remote_url))
# check if we need to cache the file # check if we need to cache the file

View File

@ -5,6 +5,7 @@ import getpass
import itertools import itertools
import json import json
import os import os
import platform
import shutil import shutil
import sys import sys
import threading import threading
@ -906,6 +907,8 @@ class StorageHelper(object):
folder_uri = str(Path(folder_uri).absolute()) folder_uri = str(Path(folder_uri).absolute())
if folder_uri.startswith('/'): if folder_uri.startswith('/'):
folder_uri = _base_url + folder_uri folder_uri = _base_url + folder_uri
elif platform.system() == "Windows":
folder_uri = ''.join((_base_url, folder_uri))
else: else:
folder_uri = '/'.join((_base_url, folder_uri)) folder_uri = '/'.join((_base_url, folder_uri))