jsbrowser: Release file system locks in the disk cache immediately

This commit is contained in:
Kovid Goyal 2013-06-11 13:22:00 +05:30
parent 8790fe9cb8
commit 8f3a202019

View File

@ -544,7 +544,14 @@ class Browser(QObject, FormsMixin):
def get_cached(self, url): def get_cached(self, url):
iod = self.nam.cache.data(QUrl(url)) iod = self.nam.cache.data(QUrl(url))
if iod is not None: 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): def wait_for_resources(self, urls, timeout=default_timeout):
timeout = self.default_timeout if timeout is default_timeout else timeout timeout = self.default_timeout if timeout is default_timeout else timeout