Skip to content

Commit

Permalink
Merge pull request #30 from reid41/remove-project-dir
Browse files Browse the repository at this point in the history
can remove project dir
  • Loading branch information
reid41 authored May 27, 2024
2 parents 5994af5 + c606a1f commit 2819912
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
from flask_cors import CORS
import configparser
import os
from helper import DataHandler
from helper import (
DataHandler,
project_dir,
remove_directory,
)
import psycopg2
from psycopg2 import sql
import ast
Expand Down Expand Up @@ -235,10 +239,18 @@ def delete_session(session_id):
cursor = conn.cursor()

try:
cursor.execute('SELECT name FROM sessions WHERE id = %s', (session_id,))
session = cursor.fetchone()
if session:
session_name = session[0]
print("anem", session_name)
cursor.execute('DELETE FROM sessions WHERE id = %s', (session_id,))
conn.commit()
cursor.execute(sql.SQL('DROP TABLE IF EXISTS {}').format(sql.Identifier(f'session_{session_id}')))
conn.commit()
# remove the git clone project
remove_project_path = os.path.join("projects", session_name)
remove_directory(remove_project_path)
print("Session deleted successfully")
return jsonify({"message": "Session deleted successfully!"})
except Exception as e:
Expand Down Expand Up @@ -397,7 +409,6 @@ def build_file_tree(directory):
@app.route('/directory')
def directory():
current_repo_path = read_current_repo_path()
# current_repo_path = os.path.join("projects", "QA-Pilot")
if current_repo_path is None:
return jsonify({'error': 'Repository path not set or not found'}), 404
dir_tree = build_file_tree(current_repo_path) # Ensure the path points to your code directory
Expand Down

0 comments on commit 2819912

Please sign in to comment.