Fix issue when archive is on mapped drive

This commit is contained in:
twangboy 2018-05-24 17:06:05 -06:00
parent 8008fca2f6
commit 980d99d74b
No known key found for this signature in database
GPG key ID: 93FF3BDEB278C9EB

View file

@ -63,13 +63,23 @@ def _gen_checksum(path):
def _checksum_file_path(path):
relpath = '.'.join((os.path.relpath(path, __opts__['cachedir']), 'hash'))
if re.match(r'..[/\\]', relpath):
# path is a local file
relpath = salt.utils.path_join(
'local',
os.path.splitdrive(path)[-1].lstrip('/\\'),
)
try:
relpath = '.'.join((os.path.relpath(path, __opts__['cachedir']), 'hash'))
if re.match(r'..[/\\]', relpath):
# path is a local file
relpath = salt.utils.path_join(
'local',
os.path.splitdrive(path)[-1].lstrip('/\\'),
)
except ValueError as exc:
# The path is on a network drive (Windows)
if 'path is on drive' in exc.message:
relpath = salt.utils.path_join(
'network',
os.path.splitdrive(path)[-1].lstrip('/\\'),
)
else:
raise
return salt.utils.path_join(__opts__['cachedir'], 'archive_hash', relpath)