Fix restaging of resources (#5681)
Part of the resource staging process is to place downloaded/expanded files in the root stage. This was not happening when a resource stage was restaged.
This commit is contained in:
parent
12f0725e9f
commit
3fc8a71afb
@ -526,8 +526,18 @@ def __init__(self, url_or_fetch_strategy, root, resource, **kwargs):
|
|||||||
self.root_stage = root
|
self.root_stage = root
|
||||||
self.resource = resource
|
self.resource = resource
|
||||||
|
|
||||||
|
def restage(self):
|
||||||
|
super(ResourceStage, self).restage()
|
||||||
|
self._add_to_root_stage()
|
||||||
|
|
||||||
def expand_archive(self):
|
def expand_archive(self):
|
||||||
super(ResourceStage, self).expand_archive()
|
super(ResourceStage, self).expand_archive()
|
||||||
|
self._add_to_root_stage()
|
||||||
|
|
||||||
|
def _add_to_root_stage(self):
|
||||||
|
"""
|
||||||
|
Move the extracted resource to the root stage (according to placement).
|
||||||
|
"""
|
||||||
root_stage = self.root_stage
|
root_stage = self.root_stage
|
||||||
resource = self.resource
|
resource = self.resource
|
||||||
placement = os.path.basename(self.source_path) \
|
placement = os.path.basename(self.source_path) \
|
||||||
@ -535,12 +545,9 @@ def expand_archive(self):
|
|||||||
else resource.placement
|
else resource.placement
|
||||||
if not isinstance(placement, dict):
|
if not isinstance(placement, dict):
|
||||||
placement = {'': placement}
|
placement = {'': placement}
|
||||||
# Make the paths in the dictionary absolute and link
|
|
||||||
for key, value in iteritems(placement):
|
|
||||||
target_path = join_path(
|
target_path = join_path(
|
||||||
root_stage.source_path, resource.destination)
|
root_stage.source_path, resource.destination)
|
||||||
destination_path = join_path(target_path, value)
|
|
||||||
source_path = join_path(self.source_path, key)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.makedirs(target_path)
|
os.makedirs(target_path)
|
||||||
@ -550,8 +557,11 @@ def expand_archive(self):
|
|||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
for key, value in iteritems(placement):
|
||||||
|
destination_path = join_path(target_path, value)
|
||||||
|
source_path = join_path(self.source_path, key)
|
||||||
|
|
||||||
if not os.path.exists(destination_path):
|
if not os.path.exists(destination_path):
|
||||||
# Create a symlink
|
|
||||||
tty.info('Moving resource stage\n\tsource : '
|
tty.info('Moving resource stage\n\tsource : '
|
||||||
'{stage}\n\tdestination : {destination}'.format(
|
'{stage}\n\tdestination : {destination}'.format(
|
||||||
stage=source_path, destination=destination_path
|
stage=source_path, destination=destination_path
|
||||||
|
Loading…
Reference in New Issue
Block a user