diff --git a/pym/update/update.py b/pym/update/update.py index 577ab86..6c32ff0 100644 --- a/pym/update/update.py +++ b/pym/update/update.py @@ -586,6 +586,8 @@ class Update(MethodsInterface): limit=1) repdirname = path.basename(rpath) self.stash_cache(rpath, repdirname) + rpath_old = f"{rpath}_old" + makeDirectory(rpath_old) try: if Git.is_git(rpath): self.addProgress() @@ -601,19 +603,17 @@ class Update(MethodsInterface): clearDirectory(rpath) p = process(emerge, "--sync", repname, stderr=STDOUT) if p.failed(): - rpath_old = f"{rpath}_old" - makeDirectory(rpath_old) for root, dirs, files in os.walk(rpath_old): for f in files: os.replace(os.path.join(rpath_old, d), os.path.join(rpath, f)) for d in dirs: shutil.move(os.path.join(rpath_old, d), os.path.join(rpath, d)) - os.rmdir(rpath_old) raise UpdateError( _("Failed to update the {rname} repository").format( rname=repname), addon=p.read()) finally: + removeDir(rpath_old) self.unstash_cache(rpath, repdirname) return True