ticket-769
Vadim vtroshchinskiy 2024-09-16 16:32:33 +02:00
parent a92f99c4a2
commit ef41ec5a89
1 changed files with 20 additions and 0 deletions

View File

@ -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: