mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
launcher: initialize repo in a temp dir
In case something goes wrong in the initial setup of the repo dir, clone it into a temporary .repo/repo.tmp/ directory first, and then rename it only when things have finished fully. Bug: https://crbug.com/gerrit/13526 Change-Id: Ib0f5a975e4d436b0fb616fac70f5789c4e02a61a Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/343537 Reviewed-by: LaMont Jones <lamontjones@google.com> Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
8a54a7eac3
commit
a010a9f4a0
7
repo
7
repo
@ -615,7 +615,9 @@ def _Init(args, gitc_init=False):
|
|||||||
try:
|
try:
|
||||||
if not opt.quiet:
|
if not opt.quiet:
|
||||||
print('Downloading Repo source from', url)
|
print('Downloading Repo source from', url)
|
||||||
dst = os.path.abspath(os.path.join(repodir, S_repo))
|
dst_final = os.path.abspath(os.path.join(repodir, S_repo))
|
||||||
|
dst = dst_final + '.tmp'
|
||||||
|
shutil.rmtree(dst, ignore_errors=True)
|
||||||
_Clone(url, dst, opt.clone_bundle, opt.quiet, opt.verbose)
|
_Clone(url, dst, opt.clone_bundle, opt.quiet, opt.verbose)
|
||||||
|
|
||||||
remote_ref, rev = check_repo_rev(dst, rev, opt.repo_verify, quiet=opt.quiet)
|
remote_ref, rev = check_repo_rev(dst, rev, opt.repo_verify, quiet=opt.quiet)
|
||||||
@ -625,6 +627,8 @@ def _Init(args, gitc_init=False):
|
|||||||
print("warning: '%s' does not look like a git-repo repository, is "
|
print("warning: '%s' does not look like a git-repo repository, is "
|
||||||
"REPO_URL set correctly?" % url, file=sys.stderr)
|
"REPO_URL set correctly?" % url, file=sys.stderr)
|
||||||
|
|
||||||
|
os.rename(dst, dst_final)
|
||||||
|
|
||||||
except CloneFailure:
|
except CloneFailure:
|
||||||
print('fatal: double check your --repo-rev setting.', file=sys.stderr)
|
print('fatal: double check your --repo-rev setting.', file=sys.stderr)
|
||||||
if opt.quiet:
|
if opt.quiet:
|
||||||
@ -1320,6 +1324,7 @@ def main(orig_args):
|
|||||||
print("fatal: cloning the git-repo repository failed, will remove "
|
print("fatal: cloning the git-repo repository failed, will remove "
|
||||||
"'%s' " % path, file=sys.stderr)
|
"'%s' " % path, file=sys.stderr)
|
||||||
shutil.rmtree(path, ignore_errors=True)
|
shutil.rmtree(path, ignore_errors=True)
|
||||||
|
shutil.rmtree(path + '.tmp', ignore_errors=True)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
repo_main, rel_repo_dir = _FindRepo()
|
repo_main, rel_repo_dir = _FindRepo()
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user