From 8f3a2020197cfaecccc100221772c879c7dfa3c1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 11 Jun 2013 13:22:00 +0530 Subject: [PATCH] jsbrowser: Release file system locks in the disk cache immediately --- src/calibre/web/jsbrowser/browser.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/calibre/web/jsbrowser/browser.py b/src/calibre/web/jsbrowser/browser.py index d016b8f09b..f71b5c3d26 100644 --- a/src/calibre/web/jsbrowser/browser.py +++ b/src/calibre/web/jsbrowser/browser.py @@ -544,7 +544,14 @@ class Browser(QObject, FormsMixin): def get_cached(self, url): iod = self.nam.cache.data(QUrl(url)) if iod is not None: - return bytes(bytearray(iod.readAll())) + try: + return bytes(bytearray(iod.readAll())) + finally: + # Ensure the IODevice is closed right away, so that the + # underlying file can be deleted if the space is needed, + # otherwise on windows the file stays locked + iod.close() + del iod def wait_for_resources(self, urls, timeout=default_timeout): timeout = self.default_timeout if timeout is default_timeout else timeout