Skip to content

Commit

Permalink
Move working-directory to master location when permitted.
Browse files Browse the repository at this point in the history
closes #2237
  • Loading branch information
jortel committed Sep 9, 2016
1 parent f30fe38 commit 8e8d58f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion server/pulp/plugins/util/publish_step.py
Expand Up @@ -896,7 +896,16 @@ def process_main(self, item=None):
# for items where http & https are published to a separate directory

_logger.debug('Copying tree from %s to %s' % (self.source_dir, timestamp_master_dir))
copytree(self.source_dir, timestamp_master_dir, symlinks=True)

misc.mkdir(os.path.dirname(timestamp_master_dir))

try:
os.rename(self.source_dir, timestamp_master_dir)
except OSError as e:
if e.errno == errno.EXDEV:
copytree(self.source_dir, timestamp_master_dir, symlinks=True)
else:
raise

for source_relative_location, publish_location in self.publish_locations:
if source_relative_location.startswith('/'):
Expand Down
4 changes: 2 additions & 2 deletions server/test/unit/plugins/util/test_publish_step.py
Expand Up @@ -748,7 +748,7 @@ def test_process_main_only_publish_directory_contents(self):
touch(sub_file)

# create an existing file that will be maintained
existing_file = os.path.join(source_dir, 'bar.html')
existing_file = os.path.join(publish_dir, 'existing.html')
touch(existing_file)

# Create an old directory to test
Expand All @@ -757,7 +757,7 @@ def test_process_main_only_publish_directory_contents(self):
step.process_main()

target_file = os.path.join(publish_dir, 'bar.html')
self.assertEquals(True, os.path.exists(target_file))
self.assertTrue(os.path.exists(target_file))
self.assertTrue(os.path.exists(existing_file))
self.assertEquals(1, len(os.listdir(master_dir)))

Expand Down

0 comments on commit 8e8d58f

Please sign in to comment.