Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change move to copy build dir during an upgrade #1429

Merged
merged 2 commits into from
Jul 9, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions core/src/epicli/cli/engine/UpgradeEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,8 @@ def backup_build(self):
backup_dir_name = f'backup_{int(round(time.time() * 1000))}'
backup_temp_dir = os.path.join(self.build_dir, '../', backup_dir_name)
rafzei marked this conversation as resolved.
Show resolved Hide resolved
self.backup_build_dir = os.path.join(self.build_dir, backup_dir_name )
self.logger.info(f'Backing up old build files to "{self.backup_build_dir}"')
shutil.move(self.build_dir, backup_temp_dir, copy_function = shutil.copytree)
if not os.path.exists(self.build_dir):
os.mkdir(self.build_dir)
shutil.move(backup_temp_dir, self.backup_build_dir, copy_function = shutil.copytree)
self.logger.info(f'Backing up build dir to "{self.backup_build_dir}"')
shutil.copytree(self.build_dir, self.backup_build_dir)
rafzei marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look at this part of Python 3.7 documentation (https://docs.python.org/3.7/library/shutil.html#shutil.copytree):

shutil.copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2, ignore_dangling_symlinks=False)
Recursively copy an entire directory tree rooted at src, returning the destination directory. The destination directory, named by dst, must not already exist;

It clearly states that the directory must not exist. Of course the name is a timestamp basically, but personally I would be extra paranoid here (but that just maybe me idk, please ignore if you think it's not a valid suggestion) \:D/.


def upgrade(self):
# backup existing build
Expand Down