AOSSIE-Org / AOSSIE-Org/PictoPy

Feat: Backend Implementation for Image deletion

Đang mở
#1,095 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
283
Fork
679
Merge trung bình
7 ngày 2 giờ
Pull request đã merge (30 ngày)
3

Mô tả

### Describe the feature

**Continuation of #802 – Add Context Menu (Right-Click) Actions for Images**

### Backend:

- Has no API to delete images
- Does not remove files from disk
- Does not clean up database records or thumbnails
- This results in an incomplete and misleading UX.

### Problem

**There is no end-to-end flow for deleting an image:**

- No backend endpoint for deletion
- No filesystem cleanup
- No database cleanup
- Frontend delete button not wired to any API
- Deleted images can reappear after refresh or restart

### Goal

1. Implement complete image deletion support, including:
2. Backend API to delete images safely
3. Frontend wiring to trigger deletion
4. Proper cleanup of files, thumbnails, and database records
5. Gallery refresh after deletion

### Expected Behavior

**When a user clicks Delete Image from the context menu:**
**Frontend sends delete request to backend**

### Backend:

1. Deletes image file from disk
2. Deletes thumbnail / cached files
3. Removes image record from database
4. Frontend updates gallery state immediately

**Proper error handling if:**

File is missing
File is locked
DB record does not exist

### Scope
**Backend (Primary)**

### Files to Update / Create

Backend (Python)

**Update**
```
backend/app/routes/images.py

backend/app/database/images.py

backend/app/utils/images.py (if helper required)

// Add (if needed)

backend/app/schemas/delete_image.py
```

### Frontend (Minimal Changes)

**Update**

- Context menu delete handler (existing UI)
- Gallery state refresh logic
- API Proposal

### Preferred REST-style endpoint:
```
DELETE /images/{image_id}
```

#### Alternative (if path-based deletion is required):
```
POST /images/delete
Body: { image_id | image_path }
```

### Acceptance Criteria ( Important)

- Image file is removed from disk
- Thumbnail/cached files are removed
- Database record is deleted
- Image does not reappear after refresh/restart
- UI updates instantly after deletion
- Safe error handling

### Record

- [x] I agree to follow this project's Code of Conduct
- [x] I want to work on this issue

### Add ScreenShots

## Demo video related to solution

https://github.com/user-attachments/assets/79634ffa-14b4-4a1a-af04-354505e0fa8f

### Record

- [x] I agree to follow this project's Code of Conduct
- [x] I want to work on this issue

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.