Fix backup in directory format on Windows.

This commit is contained in:
Akshay Joshi
2018-07-17 13:04:28 +01:00
committed by Dave Page
parent ba8f745f70
commit 1fc82d328c
2 changed files with 13 additions and 1 deletions

View File

@@ -243,7 +243,17 @@ def filename_with_file_manager_path(_file, create_file=True):
with open(_file, 'a'):
pass
return fs_short_path(_file)
short_path = fs_short_path(_file)
# fs_short_path() function may return empty path on Windows
# if directory doesn't exists. In that case we strip the last path
# component and get the short path.
if os.name == 'nt' and short_path == '':
base_name = os.path.basename(_file)
dir_name = os.path.dirname(_file)
short_path = fs_short_path(dir_name) + '\\' + base_name
return short_path
@blueprint.route(

View File

@@ -223,6 +223,8 @@ if IS_WIN:
buf_size = len(_path)
while True:
res = ctypes.create_unicode_buffer(buf_size)
# Note:- _GetShortPathNameW may return empty value
# if directory doesn't exist.
needed = _GetShortPathNameW(_path, res, buf_size)
if buf_size >= needed: