From: Hans-Christoph Steiner Date: Tue, 11 Apr 2017 19:29:55 +0000 (+0200) Subject: server: rely on rsync to delete files from git-mirror X-Git-Tag: 0.8~78^2~6 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=d3b9dbece968e8ce127e38a495d40eecc66fd70b;p=fdroidserver.git server: rely on rsync to delete files from git-mirror Instead of each time deleting the whole local git-mirror repo, and recreating it, this just deletes the .git/ dir, then lets the rsync in _local_sync() handle deleting anything that should no longer be in the repo. --- diff --git a/fdroidserver/server.py b/fdroidserver/server.py index 5bd14661..df8d5c80 100644 --- a/fdroidserver/server.py +++ b/fdroidserver/server.py @@ -227,24 +227,23 @@ def update_servergitmirrors(servergitmirrors, repo_section): import git # right now we support only 'repo' git-mirroring if repo_section == 'repo': - # create a new git-mirror folder - repo_dir = os.path.join('.', 'git-mirror/') - - # remove if already present - if os.path.isdir(repo_dir): - shutil.rmtree(repo_dir) + git_mirror_path = 'git-mirror' + dotgit = os.path.join(git_mirror_path, '.git') + if not os.path.isdir(git_mirror_path): + os.mkdir(git_mirror_path) + elif os.path.isdir(dotgit): + shutil.rmtree(dotgit) + + fdroid_repo_path = os.path.join(git_mirror_path, "fdroid") + _local_sync(repo_section, fdroid_repo_path) - repo = git.Repo.init(repo_dir) + repo = git.Repo.init(git_mirror_path) for mirror in servergitmirrors: hostname = re.sub(r'\W*\w+\W+(\w+).*', r'\1', mirror) repo.create_remote(hostname, mirror) logging.info('Mirroring to: ' + mirror) - # copy local 'repo' to 'git-mirror/fdroid/repo directory' with _local_sync - fdroid_repo_path = os.path.join(repo_dir, "fdroid") - _local_sync(repo_section, fdroid_repo_path) - # sadly index.add don't allow the --all parameter repo.git.add(all=True) repo.index.commit("fdroidserver git-mirror")