Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can remove project dir #30

Merged
merged 1 commit into from
May 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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