From 8b8f2ed43bdbba26b389ce9afdbac4007f8b7a28 Mon Sep 17 00:00:00 2001 From: Christoph Stahl Date: Tue, 24 Jun 2025 17:18:58 +0200 Subject: [PATCH] Added "Clear cache" button --- syng/gui.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/syng/gui.py b/syng/gui.py index 428f986..6c92330 100644 --- a/syng/gui.py +++ b/syng/gui.py @@ -607,6 +607,27 @@ class SyngGui(QMainWindow): "You need to start the client before you can import a queue.", ) + def clear_cache(self) -> None: + """ + Clear the cache directory of the client. + """ + + cache_dir = platformdirs.user_cache_dir("syng") + if os.path.exists(cache_dir): + answer = QMessageBox.question( + self, + "Clear Cache", + f"Are you sure you want to clear the cache directory at {cache_dir}?", + QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No, + ) + if answer == QMessageBox.StandardButton.Yes: + for root, dirs, files in os.walk(cache_dir, topdown=False): + for name in files: + os.remove(os.path.join(root, name)) + for name in dirs: + os.rmdir(os.path.join(root, name)) + QMessageBox.information(self, "Cache Cleared", "The cache has been cleared.") + def remove_room(self) -> None: if self.client is not None: answer = QMessageBox.question(