Merge pull request #47827 from twangboy/fix_47791

Fix issue when archive is on mapped drive
This commit is contained in:
Nicole Thomas 2018-06-06 13:18:00 -04:00 committed by GitHub
commit 5c56b8c755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,14 +63,28 @@ 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('/\\'),
)
return salt.utils.path_join(__opts__['cachedir'], 'archive_hash', relpath)
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 different drive (Windows)
if str(exc).startswith('path is on'):
drive, path = os.path.splitdrive(path)
relpath = salt.utils.path_join(
'local',
drive.rstrip(':'),
path.lstrip('/\\'),
)
else:
raise
ret = salt.utils.path_join(__opts__['cachedir'], 'archive_hash', relpath)
log.debug('Using checksum file %s for cached archive file %s', ret, path)
return ret
def _update_checksum(path):