docker upload directories fixes
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ def sync_files():
|
||||
return jsonify({'error': 'Unauthorized'}), 403
|
||||
|
||||
try:
|
||||
DATA_ROOT = '/data/rooms'
|
||||
DATA_ROOT = '/app/uploads/rooms'
|
||||
admin_user = User.query.filter_by(is_admin=True).first()
|
||||
if not admin_user:
|
||||
return jsonify({'error': 'No admin user found'}), 500
|
||||
@@ -73,7 +73,7 @@ def verify_db_state():
|
||||
return jsonify({'error': 'Unauthorized'}), 403
|
||||
|
||||
try:
|
||||
DATA_ROOT = '/data/rooms'
|
||||
DATA_ROOT = '/app/uploads/rooms'
|
||||
verification_results = {
|
||||
'rooms_checked': 0,
|
||||
'files_in_db_not_fs': [],
|
||||
@@ -208,7 +208,7 @@ def cleanup_orphaned_records():
|
||||
return jsonify({'error': 'Unauthorized'}), 403
|
||||
|
||||
try:
|
||||
DATA_ROOT = '/data/rooms'
|
||||
DATA_ROOT = '/app/uploads/rooms'
|
||||
rooms = Room.query.all()
|
||||
cleaned_records = []
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import string
|
||||
|
||||
contacts_bp = Blueprint('contacts', __name__, url_prefix='/contacts')
|
||||
|
||||
UPLOAD_FOLDER = os.path.join(os.getcwd(), 'uploads', 'profile_pics')
|
||||
UPLOAD_FOLDER = '/app/uploads/profile_pics'
|
||||
if not os.path.exists(UPLOAD_FOLDER):
|
||||
os.makedirs(UPLOAD_FOLDER)
|
||||
|
||||
|
||||
@@ -332,7 +332,7 @@ def init_routes(main_bp):
|
||||
is_admin=current_user.is_admin
|
||||
)
|
||||
|
||||
UPLOAD_FOLDER = os.path.join(os.getcwd(), 'uploads', 'profile_pics')
|
||||
UPLOAD_FOLDER = '/app/uploads/profile_pics'
|
||||
if not os.path.exists(UPLOAD_FOLDER):
|
||||
os.makedirs(UPLOAD_FOLDER)
|
||||
|
||||
|
||||
@@ -217,7 +217,6 @@ def upload_room_file(room_id):
|
||||
|
||||
# If we are overwriting, delete the trashed file record
|
||||
db.session.delete(trashed_file)
|
||||
db.session.commit()
|
||||
existing_file = None
|
||||
|
||||
file.save(file_path)
|
||||
@@ -347,6 +346,19 @@ def delete_file(room_id, filename):
|
||||
if not rf:
|
||||
return jsonify({'error': 'File not found'}), 404
|
||||
|
||||
# If it's a folder, mark all contained items as deleted
|
||||
if rf.type == 'folder':
|
||||
folder_path = os.path.join(rf.path, rf.name) if rf.path else rf.name
|
||||
contained_items = RoomFile.query.filter(
|
||||
RoomFile.room_id == room_id,
|
||||
RoomFile.path.like(f"{folder_path}%")
|
||||
).all()
|
||||
|
||||
for item in contained_items:
|
||||
item.deleted = True
|
||||
item.deleted_by = current_user.id
|
||||
item.deleted_at = datetime.utcnow()
|
||||
|
||||
# Mark as deleted and record who deleted it and when
|
||||
rf.deleted = True
|
||||
rf.deleted_by = current_user.id
|
||||
@@ -1052,6 +1064,9 @@ def delete_permanent(room_id):
|
||||
|
||||
for item in contained_items:
|
||||
db.session.delete(item)
|
||||
|
||||
# Delete the database record
|
||||
db.session.delete(rf)
|
||||
|
||||
log_event(
|
||||
event_type='file_delete_permanent',
|
||||
@@ -1066,10 +1081,15 @@ def delete_permanent(room_id):
|
||||
user_id=current_user.id
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Error deleting {rf.type} from storage: {e}")
|
||||
|
||||
# Delete the database record
|
||||
db.session.delete(rf)
|
||||
print(f"Error deleting file {rf.name}: {str(e)}")
|
||||
continue
|
||||
|
||||
# Commit all changes
|
||||
try:
|
||||
db.session.commit()
|
||||
except Exception as e:
|
||||
print(f"Error committing changes: {str(e)}")
|
||||
db.session.rollback()
|
||||
return jsonify({'error': 'Failed to delete files'}), 500
|
||||
|
||||
db.session.commit()
|
||||
return jsonify({'success': True})
|
||||
@@ -346,7 +346,7 @@ def delete_room(room_id):
|
||||
print(f"Attempting to delete room {room_id} ({room_name})")
|
||||
|
||||
# Delete physical files
|
||||
room_dir = os.path.join('/data/rooms', str(room_id))
|
||||
room_dir = os.path.join('/app/uploads/rooms', str(room_id))
|
||||
if os.path.exists(room_dir):
|
||||
shutil.rmtree(room_dir)
|
||||
print(f"Deleted room directory: {room_dir}")
|
||||
|
||||
Reference in New Issue
Block a user