mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #47827 from twangboy/fix_47791
Fix issue when archive is on mapped drive
This commit is contained in:
commit
5c56b8c755
1 changed files with 22 additions and 8 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Reference in a new issue