diff --git a/pym/update/update.py b/pym/update/update.py index 8c0e8a1..0f8a972 100644 --- a/pym/update/update.py +++ b/pym/update/update.py @@ -230,6 +230,8 @@ class Update(MethodsInterface): status = git.getStatusInfo(rpath) if not status or status['files']: need_update = True + + except GitError as e: need_update = True if need_update: @@ -431,8 +433,18 @@ class Update(MethodsInterface): cb_progress=self.setProgress, clean=check_status, notask=fallback_sync) - removeDir(rpath) - shutil.move(rpath_new, rpath) + if not isinstance(e, NotGitError): + removeDir(rpath) + shutil.move(rpath_new, rpath) + else: + #delete everything in rpath dir, but not rpath itself + for root, dirs, files in os.walk(rpath): + for f in files: + os.unlink(os.path.join(root, f)) + for d in dirs: + shutil.rmtree(os.path.join(root, d)) + for i in os.listdir(rpath_new): + shutil.move(os.path.join(rpath_new, i), rpath) except OSError as e: raise UpdateError(_("Failed to modify the " "{repname} repository").format(