Ticket #737: GC
parent
a92f99c4a2
commit
ef41ec5a89
|
@ -51,6 +51,12 @@ def do_repo_sync(repo, params):
|
|||
|
||||
return results
|
||||
|
||||
def do_repo_gc(repo):
|
||||
gitrepo = git.Repo(f"{repositories_base_path}/{repo}.git")
|
||||
|
||||
gitrepo.git.gc()
|
||||
return True
|
||||
|
||||
|
||||
# Define a route for the root URL
|
||||
@app.route('/')
|
||||
|
@ -144,6 +150,20 @@ def backup_repo(repo):
|
|||
|
||||
#return jsonify({"status": "Started backup", "repository" : repo, "ssh_server" : dest_server, "ssh_user" : dest_user, "filename" : dest_file}), 200
|
||||
|
||||
@app.route('/repositories/<repo>/gc', methods=['POST'])
|
||||
def gc_repo(repo):
|
||||
|
||||
repo_path = os.path.join(repositories_base_path, repo + ".git")
|
||||
if not os.path.isdir(repo_path):
|
||||
return jsonify({"error": "Repository not found"}), 404
|
||||
|
||||
future = executor.submit(do_repo_gc, repo)
|
||||
task_id = str(uuid.uuid4())
|
||||
tasks[task_id] = future
|
||||
|
||||
return jsonify({"status": "started", "task_id" : task_id}), 200
|
||||
|
||||
|
||||
@app.route('/tasks/<task_id>/status')
|
||||
def tasks_status(task_id):
|
||||
if not task_id in tasks:
|
||||
|
|
Loading…
Reference in New Issue