refactor(media): Vereinsflache Ablage; private als u{profile} unter Verein
- club: library/club/c{id}/{sha} (kein shared/)
- private: library/club/c{id}/u{profile}/{sha} statt …/private/
- Dedupe private: sha + club_id + uploaded_by_profile_id
- version 0.8.54
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3f0d02edab
commit
8d85649cf8
6 files changed
+103
-39
No files matched your search
@@ -63,16 +63,17 @@ def library_storage_key(
|
||||
club_id: Optional[int],
|
||||
sha256_hex: str,
|
||||
ext: str,
|
||||
*,
|
||||
uploader_profile_id: Optional[int] = None,
|
||||
) -> str:
|
||||
"""
|
||||
Relativer Speicherpfad unter MEDIA_ROOT für lokale media_assets.
|
||||
|
||||
Layout (nach Verein gegliedert, globale Medien getrennt):
|
||||
- private → library/club/c{club_id}/private/{sha256}{ext}
|
||||
- club (Vereinssichtbarkeit) → library/club/c{club_id}/shared/{sha256}{ext}
|
||||
- official → library/official/{sha256}{ext}
|
||||
- club (vereinsgeteilt) → library/club/c{club_id}/{sha256}{ext}
|
||||
- private (nur Hochlader, Governance unverändert) → library/club/c{club_id}/u{profile}/{sha256}{ext}
|
||||
|
||||
club_id ist bei private/club zwingend (Vereinsordner); bei official nicht genutzt.
|
||||
Kein Ordnername „private“ auf der Platte: Zuordnung erfolgt über Uploader unter dem Verein.
|
||||
"""
|
||||
vis = (visibility or "private").strip().lower()
|
||||
if vis not in ("private", "club", "official"):
|
||||
@@ -99,9 +100,14 @@ def library_storage_key(
|
||||
cid = int(club_id)
|
||||
if cid < 1:
|
||||
raise ValueError("club_id muss eine positive Ganzzahl sein")
|
||||
if vis == "private":
|
||||
return f"library/club/c{cid}/private/{blob}"
|
||||
return f"library/club/c{cid}/shared/{blob}"
|
||||
if vis == "club":
|
||||
return f"library/club/c{cid}/{blob}"
|
||||
if uploader_profile_id is None:
|
||||
raise ValueError("uploader_profile_id ist für private Medien erforderlich (Ordner u{…} unter dem Verein)")
|
||||
up = int(uploader_profile_id)
|
||||
if up < 1:
|
||||
raise ValueError("uploader_profile_id muss positiv sein")
|
||||
return f"library/club/c{cid}/u{up}/{blob}"
|
||||
|
||||
|
||||
def relocate_local_media_file(media_root: Path, old_storage_key: str, new_storage_key: str) -> None:
|
||||
|
||||
Reference in new issue
Block a user