stage: fix resources being deleted from local cache (#10152)
Non-expanded resources were being deleted from the cache on account of two behaviors: * ResourceStage was moving files rather than copying them, and uses "os.path.realpath" to resolve symlinks * CacheFetchStrategy creates a symlink to a cached resource rather than copying it This alters the first behavior: ResourceStage now copies the file rather than moving it.
This commit is contained in:
parent
5450303c97
commit
41ef02ee10
@ -8,7 +8,6 @@
|
||||
import sys
|
||||
import errno
|
||||
import hashlib
|
||||
import shutil
|
||||
import tempfile
|
||||
import getpass
|
||||
from six import string_types
|
||||
@ -16,7 +15,7 @@
|
||||
from six.moves.urllib.parse import urljoin
|
||||
|
||||
import llnl.util.tty as tty
|
||||
from llnl.util.filesystem import mkdirp, can_access
|
||||
from llnl.util.filesystem import mkdirp, can_access, copy, copy_tree
|
||||
from llnl.util.filesystem import remove_if_dead_link, remove_linked_tree
|
||||
|
||||
import spack.paths
|
||||
@ -406,7 +405,7 @@ def generate_fetchers():
|
||||
self.fetcher = fetcher
|
||||
self.fetcher.fetch()
|
||||
break
|
||||
except spack.fetch_strategy.NoCacheError as e:
|
||||
except spack.fetch_strategy.NoCacheError:
|
||||
# Don't bother reporting when something is not cached.
|
||||
continue
|
||||
except spack.error.SpackError as e:
|
||||
@ -545,7 +544,13 @@ def _add_to_root_stage(self):
|
||||
'{stage}\n\tdestination : {destination}'.format(
|
||||
stage=source_path, destination=destination_path
|
||||
))
|
||||
shutil.move(os.path.realpath(source_path), destination_path)
|
||||
|
||||
src = os.path.realpath(source_path)
|
||||
|
||||
if os.path.isdir(src):
|
||||
copy_tree(src, destination_path)
|
||||
else:
|
||||
copy(src, destination_path)
|
||||
|
||||
|
||||
@pattern.composite(method_list=[
|
||||
|
Loading…
Reference in New Issue
Block a user