Upload pipeline: staging, MD5 auto-match, IQDB, three-column board
Backend: - TempUpload model: staged files (pending / visual_match / completed / error) with resolution, e621 payload, custom metadata and IQDB data - Files land in a temp folder and only move into the watched library folder once resolved; duplicates resolve immediately without a copy - Endpoints: stage (multipart), list, retrieve, temp file, IQDB save, resolve (link to post or custom metadata), discard/dismiss - cleanup_temp_uploads command for old staged files - Replaces the old direct-to-library upload endpoint Frontend: - Upload page is now a three-column board (Pending & Unmatched / Visual Similarity Detected / Auto-uploaded & Indexed) - After upload: MD5s are batch-checked against e621 and matches auto-complete with full post metadata; remaining files run through IQDB and move to the similarity column when candidates exist - Metadata modal with IQDB candidates, post-ID linking and custom tags/rating/notes; discard and dismiss actions - e621 client gains fetchPostsByMd5 and iqdbSearch helpers Roadmap updated with the completed upload items.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
|
||||
import uuid
|
||||
|
||||
|
||||
class MediaItem(models.Model):
|
||||
"""A logical media file, identified by its MD5 fingerprint."""
|
||||
@@ -57,3 +59,59 @@ class MediaLocation(models.Model):
|
||||
|
||||
def __str__(self):
|
||||
return self.rel_path
|
||||
|
||||
|
||||
class TempUpload(models.Model):
|
||||
"""A staged upload that has not been accepted into the library yet."""
|
||||
|
||||
STATUS_PENDING = "pending"
|
||||
STATUS_VISUAL_MATCH = "visual_match"
|
||||
STATUS_COMPLETED = "completed"
|
||||
STATUS_ERROR = "error"
|
||||
STATUS_CHOICES = [
|
||||
(STATUS_PENDING, "Pending"),
|
||||
(STATUS_VISUAL_MATCH, "Visual Similarity Detected"),
|
||||
(STATUS_COMPLETED, "Completed"),
|
||||
(STATUS_ERROR, "Error"),
|
||||
]
|
||||
|
||||
RESOLUTION_AUTO_MD5 = "auto_md5"
|
||||
RESOLUTION_DUPLICATE = "duplicate"
|
||||
RESOLUTION_LINKED = "linked"
|
||||
RESOLUTION_CUSTOM = "custom"
|
||||
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
user = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="temp_uploads",
|
||||
)
|
||||
file = models.FileField(upload_to="uploads/temp/", blank=True)
|
||||
original_filename = models.CharField(max_length=255)
|
||||
md5 = models.CharField(max_length=32, db_index=True)
|
||||
size = models.BigIntegerField(default=0)
|
||||
status = models.CharField(
|
||||
max_length=20, choices=STATUS_CHOICES, default=STATUS_PENDING
|
||||
)
|
||||
resolution = models.CharField(max_length=20, blank=True, default="")
|
||||
e621_post_id = models.IntegerField(null=True, blank=True)
|
||||
e621_data = models.JSONField(null=True, blank=True)
|
||||
custom_rating = models.CharField(max_length=1, blank=True, default="")
|
||||
custom_tags = models.JSONField(default=list, blank=True)
|
||||
custom_notes = models.TextField(blank=True, default="")
|
||||
iqdb_data = models.JSONField(null=True, blank=True)
|
||||
library_item = models.ForeignKey(
|
||||
MediaItem,
|
||||
null=True,
|
||||
blank=True,
|
||||
on_delete=models.SET_NULL,
|
||||
related_name="temp_uploads",
|
||||
)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["-created_at"]
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.original_filename} ({self.status})"
|
||||
|
||||
Reference in New Issue
Block a user