fix: make history deletion independent of cache cleanup

This commit is contained in:
Ilgiz Kalmetyev 2026-04-10 14:31:17 +05:00
parent b6fd6c2369
commit 9058cf7404
2 changed files with 4 additions and 2 deletions

View File

@ -367,6 +367,8 @@ class HistoryDialog(QDialog):
if deleted_count <= 0:
return False
self.refresh_records()
if self._audio_cache_service is not None and deleted_count == record_count:
try:
removed_count = self._audio_cache_service.delete_cached_files(
@ -381,7 +383,6 @@ class HistoryDialog(QDialog):
except Exception as exc:
QMessageBox.warning(self, "Audio cache", f"Unable to delete cached audio files: {exc}")
self.refresh_records()
return True
def _set_record_row(self, row_index: int, record: HistoryRecord) -> None:

View File

@ -258,6 +258,8 @@ class SettingsController(QObject):
QMessageBox.warning(self._window, "History", message)
return
dialog.set_history_usage_summary(0)
if self._audio_cache_service is not None:
try:
removed_cache_files = self._audio_cache_service.delete_cached_files(record.audio_cache_path for record in records)
@ -266,7 +268,6 @@ class SettingsController(QObject):
except Exception as exc:
self._logger.warning("Unable to remove cached audio files while clearing history: %s", exc)
dialog.set_history_usage_summary(0)
message = f"Cleared {deleted} history record(s)."
self._window.set_status_message(message)
self._logger.info(message)