docker upload directories fixes

This commit is contained in:
2025-06-06 10:12:46 +02:00
parent e4238d9fdb
commit d619283d09
16 changed files with 62 additions and 23 deletions

View File

@@ -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})