Karan Adhikari commited on
Update database.py
Browse files- Backend/helper/database.py +0 -21
Backend/helper/database.py
CHANGED
|
@@ -844,12 +844,6 @@ class Database:
|
|
| 844 |
return result
|
| 845 |
|
| 846 |
async def _delete_quality_media(self, quality: dict) -> None:
|
| 847 |
-
"""Delete the underlying Telegram message(s) backing a single quality entry.
|
| 848 |
-
|
| 849 |
-
Works for both normal (single message) entries and split groups (one
|
| 850 |
-
message per part). Failures are logged but never raised so a failed
|
| 851 |
-
Telegram delete can't abort the database update.
|
| 852 |
-
"""
|
| 853 |
parts = quality.get("parts")
|
| 854 |
if parts:
|
| 855 |
for part in parts:
|
|
@@ -875,18 +869,6 @@ class Database:
|
|
| 875 |
async def _apply_quality_update(
|
| 876 |
self, existing_qualities: List[dict], quality_to_update: dict
|
| 877 |
) -> List[dict]:
|
| 878 |
-
"""Merge an incoming quality entry into an existing list of qualities.
|
| 879 |
-
|
| 880 |
-
Handles three scenarios:
|
| 881 |
-
* Incoming split part: merge with the matching split group. When
|
| 882 |
-
REPLACE_MODE is on, any other version of the same quality (a normal
|
| 883 |
-
file or a different split group) is deleted first so only the new
|
| 884 |
-
split group survives.
|
| 885 |
-
* Incoming normal file with REPLACE_MODE on: delete every existing
|
| 886 |
-
entry of the same quality (normal file or split group, including all
|
| 887 |
-
split parts) and keep only the new normal file.
|
| 888 |
-
* REPLACE_MODE off: keep existing entries and append the new one.
|
| 889 |
-
"""
|
| 890 |
target_quality = quality_to_update.get("quality")
|
| 891 |
incoming_group_key = quality_to_update.get("group_key")
|
| 892 |
replace_mode = SettingsManager.current().replace_mode
|
|
@@ -894,9 +876,6 @@ class Database:
|
|
| 894 |
if incoming_group_key:
|
| 895 |
# Incoming is a split part.
|
| 896 |
if replace_mode:
|
| 897 |
-
# Remove any other version of this quality (a normal file or a
|
| 898 |
-
# different split group); the matching split group is preserved
|
| 899 |
-
# so its parts can be merged below.
|
| 900 |
stale = [
|
| 901 |
q for q in existing_qualities
|
| 902 |
if q.get("quality") == target_quality
|
|
|
|
| 844 |
return result
|
| 845 |
|
| 846 |
async def _delete_quality_media(self, quality: dict) -> None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 847 |
parts = quality.get("parts")
|
| 848 |
if parts:
|
| 849 |
for part in parts:
|
|
|
|
| 869 |
async def _apply_quality_update(
|
| 870 |
self, existing_qualities: List[dict], quality_to_update: dict
|
| 871 |
) -> List[dict]:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 872 |
target_quality = quality_to_update.get("quality")
|
| 873 |
incoming_group_key = quality_to_update.get("group_key")
|
| 874 |
replace_mode = SettingsManager.current().replace_mode
|
|
|
|
| 876 |
if incoming_group_key:
|
| 877 |
# Incoming is a split part.
|
| 878 |
if replace_mode:
|
|
|
|
|
|
|
|
|
|
| 879 |
stale = [
|
| 880 |
q for q in existing_qualities
|
| 881 |
if q.get("quality") == target_quality
|