forked from Mirrors/RGSX
v2.2.2.7
- Add checks for existing files before download and update status messages in multiple languages
This commit is contained in:
@@ -13,7 +13,7 @@ except Exception:
|
||||
pygame = None # type: ignore
|
||||
|
||||
# Version actuelle de l'application
|
||||
app_version = "2.2.2.6"
|
||||
app_version = "2.2.2.7"
|
||||
|
||||
|
||||
def get_application_root():
|
||||
|
||||
@@ -117,6 +117,8 @@
|
||||
"network_api_error": "Fehler bei der API-Anfrage, der Schlüssel könnte falsch sein: {0}",
|
||||
"network_download_error": "Downloadfehler {0}: {1}",
|
||||
"network_download_ok": "Download erfolgreich: {0}",
|
||||
"download_already_present": " (bereits vorhanden)",
|
||||
"download_already_extracted": " (bereits extrahiert)",
|
||||
"utils_extracted": "Extrahiert: {0}",
|
||||
"utils_corrupt_zip": "Beschädigtes ZIP-Archiv: {0}",
|
||||
"utils_permission_denied": "Berechtigung während der Extraktion verweigert: {0}",
|
||||
@@ -196,5 +198,6 @@
|
||||
,"controls_mapping_instruction": "Zum Bestätigen gedrückt halten:"
|
||||
,"controls_mapping_waiting": "Warte auf eine Taste oder einen Button..."
|
||||
,"controls_mapping_press": "Drücke eine Taste oder einen Button"
|
||||
,"status_already_present": "Bereits Vorhanden"
|
||||
,"footer_joystick": "Joystick: {0}"
|
||||
}
|
||||
@@ -104,6 +104,8 @@
|
||||
"network_api_error": "API request error, the key may be incorrect: {0}",
|
||||
"network_download_error": "Download error {0}: {1}",
|
||||
"network_download_ok": "Download OK: {0}",
|
||||
"download_already_present": " (already present)",
|
||||
"download_already_extracted": " (already extracted)",
|
||||
"utils_extracted": "Extracted: {0}",
|
||||
"utils_corrupt_zip": "Corrupted ZIP archive: {0}",
|
||||
"utils_permission_denied": "Permission denied during extraction: {0}",
|
||||
@@ -196,5 +198,6 @@
|
||||
,"controls_mapping_instruction": "Hold to confirm the mapping:"
|
||||
,"controls_mapping_waiting": "Waiting for a key or button..."
|
||||
,"controls_mapping_press": "Press a key or a button"
|
||||
,"status_already_present": "Already Present"
|
||||
,"footer_joystick": "Joystick: {0}"
|
||||
}
|
||||
@@ -117,6 +117,8 @@
|
||||
"network_api_error": "Error en la solicitud de API, la clave puede ser incorrecta: {0}",
|
||||
"network_download_error": "Error en la descarga {0}: {1}",
|
||||
"network_download_ok": "Descarga exitosa: {0}",
|
||||
"download_already_present": " (ya presente)",
|
||||
"download_already_extracted": " (ya extraído)",
|
||||
"utils_extracted": "Extraído: {0}",
|
||||
"utils_corrupt_zip": "Archivo ZIP corrupto: {0}",
|
||||
"utils_permission_denied": "Permiso denegado durante la extracción: {0}",
|
||||
@@ -196,5 +198,6 @@
|
||||
,"controls_mapping_instruction": "Mantén para confirmar la asignación:"
|
||||
,"controls_mapping_waiting": "Esperando una tecla o botón..."
|
||||
,"controls_mapping_press": "Pulsa una tecla o un botón"
|
||||
,"status_already_present": "Ya Presente"
|
||||
,"footer_joystick": "Joystick: {0}"
|
||||
}
|
||||
@@ -117,6 +117,8 @@
|
||||
"network_api_error": "Erreur lors de la requête API, la clé est peut-être incorrecte: {0}",
|
||||
"network_download_error": "Erreur téléchargement {0}: {1}",
|
||||
"network_download_ok": "Téléchargement ok : {0}",
|
||||
"download_already_present": " (déjà présent)",
|
||||
"download_already_extracted": " (déjà extrait)",
|
||||
"utils_extracted": "Extracted: {0}",
|
||||
"utils_corrupt_zip": "Archive ZIP corrompue: {0}",
|
||||
"utils_permission_denied": "Permission refusée lors de l'extraction: {0}",
|
||||
@@ -196,5 +198,6 @@
|
||||
,"controls_mapping_instruction": "Maintenez pour confirmer l'association :"
|
||||
,"controls_mapping_waiting": "En attente d'une touche ou d'un bouton..."
|
||||
,"controls_mapping_press": "Appuyez sur une touche ou un bouton"
|
||||
,"status_already_present": "Déjà Présent"
|
||||
,"footer_joystick": "Joystick : {0}"
|
||||
}
|
||||
@@ -104,6 +104,8 @@
|
||||
"network_api_error": "Errore richiesta API, la chiave potrebbe essere errata: {0}",
|
||||
"network_download_error": "Errore download {0}: {1}",
|
||||
"network_download_ok": "Download OK: {0}",
|
||||
"download_already_present": " (già presente)",
|
||||
"download_already_extracted": " (già estratto)",
|
||||
"utils_extracted": "Estratto: {0}",
|
||||
"utils_corrupt_zip": "Archivio ZIP corrotto: {0}",
|
||||
"utils_permission_denied": "Permesso negato durante l'estrazione: {0}",
|
||||
@@ -196,5 +198,6 @@
|
||||
,"controls_mapping_instruction": "Tieni premuto per confermare l'associazione:"
|
||||
,"controls_mapping_waiting": "In attesa di un tasto o pulsante..."
|
||||
,"controls_mapping_press": "Premi un tasto o un pulsante"
|
||||
,"status_already_present": "Già Presente"
|
||||
,"footer_joystick": "Joystick: {0}"
|
||||
}
|
||||
@@ -104,6 +104,8 @@
|
||||
"network_api_error": "Erro na requisição da API, a chave pode estar incorreta: {0}",
|
||||
"network_download_error": "Erro de download {0}: {1}",
|
||||
"network_download_ok": "Download OK: {0}",
|
||||
"download_already_present": " (já presente)",
|
||||
"download_already_extracted": " (já extraído)",
|
||||
"utils_extracted": "Extraído: {0}",
|
||||
"utils_corrupt_zip": "Arquivo ZIP corrompido: {0}",
|
||||
"utils_permission_denied": "Permissão negada durante extração: {0}",
|
||||
@@ -196,5 +198,6 @@
|
||||
,"controls_mapping_instruction": "Mantenha para confirmar o mapeamento:"
|
||||
,"controls_mapping_waiting": "Aguardando uma tecla ou botão..."
|
||||
,"controls_mapping_press": "Pressione uma tecla ou um botão"
|
||||
,"status_already_present": "Já Presente"
|
||||
,"footer_joystick": "Joystick: {0}"
|
||||
}
|
||||
@@ -354,6 +354,51 @@ async def download_rom(url, platform, game_name, is_zip_non_supported=False, tas
|
||||
dest_path = os.path.join(dest_dir, f"{sanitized_name}")
|
||||
logger.debug(f"Chemin destination: {dest_path}")
|
||||
|
||||
# Vérifier si le fichier existe déjà (exact ou avec autre extension)
|
||||
if os.path.exists(dest_path):
|
||||
logger.info(f"Le fichier {dest_path} existe déjà, téléchargement ignoré")
|
||||
result[0] = True
|
||||
result[1] = _("network_download_ok").format(game_name) + _("download_already_present")
|
||||
# Mettre à jour l'historique avec un statut spécifique
|
||||
if isinstance(config.history, list):
|
||||
for entry in config.history:
|
||||
if "url" in entry and entry["url"] == url:
|
||||
entry["status"] = "Already_Present"
|
||||
entry["progress"] = 100
|
||||
entry["message"] = result[1]
|
||||
save_history(config.history)
|
||||
config.needs_redraw = True
|
||||
break
|
||||
return
|
||||
|
||||
# Vérifier si un fichier avec le même nom de base mais extension différente existe
|
||||
base_name_no_ext = os.path.splitext(sanitized_name)[0]
|
||||
if base_name_no_ext != sanitized_name: # Seulement si une extension était présente
|
||||
try:
|
||||
# Lister tous les fichiers dans le répertoire de destination
|
||||
if os.path.exists(dest_dir):
|
||||
for existing_file in os.listdir(dest_dir):
|
||||
existing_base = os.path.splitext(existing_file)[0]
|
||||
if existing_base == base_name_no_ext:
|
||||
existing_path = os.path.join(dest_dir, existing_file)
|
||||
logger.info(f"Un fichier avec le même nom de base existe déjà: {existing_path}, téléchargement ignoré")
|
||||
result[0] = True
|
||||
result[1] = _("network_download_ok").format(game_name) + _("download_already_extracted")
|
||||
# Mettre à jour l'historique avec un statut spécifique
|
||||
if isinstance(config.history, list):
|
||||
for entry in config.history:
|
||||
if "url" in entry and entry["url"] == url:
|
||||
entry["status"] = "Already_Present"
|
||||
entry["progress"] = 100
|
||||
entry["message"] = result[1]
|
||||
save_history(config.history)
|
||||
config.needs_redraw = True
|
||||
break
|
||||
return
|
||||
except Exception as e:
|
||||
logger.debug(f"Erreur lors de la vérification des fichiers existants: {e}")
|
||||
|
||||
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
|
||||
@@ -813,6 +858,51 @@ async def download_from_1fichier(url, platform, game_name, is_zip_non_supported=
|
||||
sanitized_filename = sanitize_filename(filename)
|
||||
dest_path = os.path.join(dest_dir, sanitized_filename)
|
||||
logger.debug(f"Chemin destination: {dest_path}")
|
||||
|
||||
# Vérifier si le fichier existe déjà (exact ou avec autre extension)
|
||||
if os.path.exists(dest_path):
|
||||
logger.info(f"Le fichier {dest_path} existe déjà, téléchargement ignoré")
|
||||
result[0] = True
|
||||
result[1] = _("network_download_ok").format(game_name) + _("download_already_present")
|
||||
# Mettre à jour l'historique avec un statut spécifique
|
||||
if isinstance(config.history, list):
|
||||
for entry in config.history:
|
||||
if "url" in entry and entry["url"] == url:
|
||||
entry["status"] = "Already_Present"
|
||||
entry["progress"] = 100
|
||||
entry["message"] = result[1]
|
||||
save_history(config.history)
|
||||
config.needs_redraw = True
|
||||
break
|
||||
return
|
||||
|
||||
# Vérifier si un fichier avec le même nom de base mais extension différente existe
|
||||
base_name_no_ext = os.path.splitext(sanitized_filename)[0]
|
||||
if base_name_no_ext != sanitized_filename: # Seulement si une extension était présente
|
||||
try:
|
||||
# Lister tous les fichiers dans le répertoire de destination
|
||||
if os.path.exists(dest_dir):
|
||||
for existing_file in os.listdir(dest_dir):
|
||||
existing_base = os.path.splitext(existing_file)[0]
|
||||
if existing_base == base_name_no_ext:
|
||||
existing_path = os.path.join(dest_dir, existing_file)
|
||||
logger.info(f"Un fichier avec le même nom de base existe déjà: {existing_path}, téléchargement ignoré")
|
||||
result[0] = True
|
||||
result[1] = _("network_download_ok").format(game_name) + _("download_already_extracted")
|
||||
# Mettre à jour l'historique avec un statut spécifique
|
||||
if isinstance(config.history, list):
|
||||
for entry in config.history:
|
||||
if "url" in entry and entry["url"] == url:
|
||||
entry["status"] = "Already_Present"
|
||||
entry["progress"] = 100
|
||||
entry["message"] = result[1]
|
||||
save_history(config.history)
|
||||
config.needs_redraw = True
|
||||
break
|
||||
return
|
||||
except Exception as e:
|
||||
logger.debug(f"Erreur lors de la vérification des fichiers existants: {e}")
|
||||
|
||||
logger.debug(f"Envoi requête 1fichier get_token pour {link}")
|
||||
response = requests.post("https://api.1fichier.com/v1/download/get_token.cgi", headers=headers, json=payload, timeout=30)
|
||||
status_1f = response.status_code
|
||||
@@ -1014,6 +1104,50 @@ async def download_from_1fichier(url, platform, game_name, is_zip_non_supported=
|
||||
filename = game_name
|
||||
sanitized_filename = sanitize_filename(filename)
|
||||
dest_path = os.path.join(dest_dir, sanitized_filename)
|
||||
|
||||
# Vérifier si le fichier existe déjà (exact ou avec autre extension)
|
||||
if os.path.exists(dest_path):
|
||||
logger.info(f"Le fichier {dest_path} existe déjà, téléchargement ignoré")
|
||||
result[0] = True
|
||||
result[1] = _("network_download_ok").format(game_name) + _("download_already_present")
|
||||
# Mettre à jour l'historique avec un statut spécifique
|
||||
if isinstance(config.history, list):
|
||||
for entry in config.history:
|
||||
if "url" in entry and entry["url"] == url:
|
||||
entry["status"] = "Already_Present"
|
||||
entry["progress"] = 100
|
||||
entry["message"] = result[1]
|
||||
save_history(config.history)
|
||||
config.needs_redraw = True
|
||||
break
|
||||
return
|
||||
|
||||
# Vérifier si un fichier avec le même nom de base mais extension différente existe
|
||||
base_name_no_ext = os.path.splitext(sanitized_filename)[0]
|
||||
if base_name_no_ext != sanitized_filename: # Seulement si une extension était présente
|
||||
try:
|
||||
# Lister tous les fichiers dans le répertoire de destination
|
||||
if os.path.exists(dest_dir):
|
||||
for existing_file in os.listdir(dest_dir):
|
||||
existing_base = os.path.splitext(existing_file)[0]
|
||||
if existing_base == base_name_no_ext:
|
||||
existing_path = os.path.join(dest_dir, existing_file)
|
||||
logger.info(f"Un fichier avec le même nom de base existe déjà: {existing_path}, téléchargement ignoré")
|
||||
result[0] = True
|
||||
result[1] = _("network_download_ok").format(game_name) + _("download_already_extracted")
|
||||
# Mettre à jour l'historique avec un statut spécifique
|
||||
if isinstance(config.history, list):
|
||||
for entry in config.history:
|
||||
if "url" in entry and entry["url"] == url:
|
||||
entry["status"] = "Already_Present"
|
||||
entry["progress"] = 100
|
||||
entry["message"] = result[1]
|
||||
save_history(config.history)
|
||||
config.needs_redraw = True
|
||||
break
|
||||
return
|
||||
except Exception as e:
|
||||
logger.debug(f"Erreur lors de la vérification des fichiers existants: {e}")
|
||||
lock = threading.Lock()
|
||||
retries = 10
|
||||
retry_delay = 10
|
||||
|
||||
Reference in New Issue
Block a user