From d98912ca6b9a82956b8c6f0fb78cef3dbfb7450c Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 3 Dec 2022 23:30:19 +1000 Subject: [PATCH] Revert "Probable workaround for mpv failing after a few days on macOS" This reverts commit fa4fc3e15a92140b695872a001d0d1e6f6f89469. Issue turned out to be a packaging problem, and this should not be required as the socket should be held open even if removed. --- qt/aqt/main.py | 20 ++++---------------- qt/aqt/sound.py | 6 ------ 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/qt/aqt/main.py b/qt/aqt/main.py index 50919890a..579c75cf4 100644 --- a/qt/aqt/main.py +++ b/qt/aqt/main.py @@ -1382,14 +1382,7 @@ title="{}" {}>{}""".format( True, parent=self, ) - if not is_win: - self.progress.timer( - 12 * 60 * 1000, - self.temp_file_workarounds, - repeat=True, - requiresCollection=False, - parent=self, - ) + self.progress.timer(12 * 60 * 1000, self.refresh_certs, False, parent=self) def onRefreshTimer(self) -> None: if self.state == "deckBrowser": @@ -1405,20 +1398,15 @@ title="{}" {}>{}""".format( if elap > minutes * 60: self.maybe_auto_sync_media() - def temp_file_workarounds(self) -> None: - import certifi - - from aqt.sound import mpvManager - + def refresh_certs(self) -> None: # The requests library copies the certs into a temporary folder on startup, # and chokes when the file is later missing due to temp file cleaners. # Work around the issue by accessing them once every 12 hours. + import certifi + with open(certifi.where(), "rb") as f: f.read() - # Prevent the mpv socket from being removed - mpvManager.bump_socket_mtime() - # Backups ########################################################################## diff --git a/qt/aqt/sound.py b/qt/aqt/sound.py index 93a379360..5839d2dae 100644 --- a/qt/aqt/sound.py +++ b/qt/aqt/sound.py @@ -404,12 +404,6 @@ class MpvManager(MPV, SoundOrVideoPlayer): self.default_argv += [f"--config-dir={base_path}"] super().__init__(window_id=None, debug=False) - def bump_socket_mtime(self) -> None: - "Update mtime on socket to prevent temp file cleaners from removing it." - path = Path(self._sock_filename) - if path.exists(): - os.utime(path, None) - def on_init(self) -> None: # if mpv dies and is restarted, tell Anki the # current file is done