mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-04-20 23:56:34 -04:00
Improve disk cache options
Remove `--disable-cache`, its not used any more. Rename `disk_cache` to `disk_cache_dir` and use only path (str) argument. Decouple `--disk-cache-size` from `--disk-cache-dir` so it is possible to use either or both.
This commit is contained in:
parent
c288c9ae98
commit
31e611771e
@ -63,7 +63,7 @@ class Chrome:
|
||||
logger = logging.getLogger(__module__ + '.' + __qualname__)
|
||||
|
||||
def __init__(self, chrome_exe, port=9222, ignore_cert_errors=False,
|
||||
disk_cache=None, disk_cache_size=None):
|
||||
disk_cache_dir=None, disk_cache_size=None):
|
||||
'''
|
||||
Initializes instance of this class.
|
||||
|
||||
@ -80,7 +80,7 @@ class Chrome:
|
||||
self.ignore_cert_errors = ignore_cert_errors
|
||||
self._shutdown = threading.Event()
|
||||
self.chrome_process = None
|
||||
self.disk_cache = disk_cache
|
||||
self.disk_cache_dir = disk_cache_dir
|
||||
self.disk_cache_size = disk_cache_size
|
||||
|
||||
def __enter__(self):
|
||||
@ -137,7 +137,7 @@ class Chrome:
|
||||
cookie_location, exc_info=True)
|
||||
return cookie_db
|
||||
|
||||
def start(self, proxy=None, cookie_db=None, disk_cache=None,
|
||||
def start(self, proxy=None, cookie_db=None, disk_cache_dir=None,
|
||||
disk_cache_size=None):
|
||||
'''
|
||||
Starts chrome/chromium process.
|
||||
@ -148,9 +148,8 @@ class Chrome:
|
||||
which, if supplied, will be written to
|
||||
{chrome_user_data_dir}/Default/Cookies before running the
|
||||
browser (default None)
|
||||
disk_cache: use disk cache. If True, use default cache location inside
|
||||
`self._home_tmpdir`. If its a string, try to use that path for
|
||||
disk cache (default None)
|
||||
disk_cache_dir: use directory for disk cache. The default location
|
||||
is inside `self._home_tmpdir` (default None).
|
||||
disk_cache_size: Forces the maximum disk space to be used by the disk
|
||||
cache, in bytes. Used only when `cache` is a disk path.
|
||||
(default None)
|
||||
@ -163,8 +162,8 @@ class Chrome:
|
||||
self._home_tmpdir.name, 'chrome-user-data')
|
||||
if cookie_db:
|
||||
self._init_cookie_db(cookie_db)
|
||||
if disk_cache:
|
||||
self.disk_cache = disk_cache
|
||||
if disk_cache_dir:
|
||||
self.disk_cache_dir = disk_cache_dir
|
||||
if disk_cache_size:
|
||||
self.disk_cache_size = disk_cache_size
|
||||
self._shutdown.clear()
|
||||
@ -186,15 +185,10 @@ class Chrome:
|
||||
'--disable-web-security', '--disable-notifications',
|
||||
'--disable-extensions', '--disable-save-password-bubble']
|
||||
|
||||
if self.disk_cache:
|
||||
if isinstance(self.disk_cache, str):
|
||||
chrome_args.append('--disk-cache-dir=%s' % self.disk_cache)
|
||||
if self.disk_cache_size:
|
||||
chrome_args.append('--disk-cache-size=%s' %
|
||||
self.disk_cache_size)
|
||||
else:
|
||||
chrome_args.append('--disable-cache')
|
||||
|
||||
if self.disk_cache_dir:
|
||||
chrome_args.append('--disk-cache-dir=%s' % self.disk_cache_dir)
|
||||
if self.disk_cache_size:
|
||||
chrome_args.append('--disk-cache-size=%s' % self.disk_cache_size)
|
||||
if self.ignore_cert_errors:
|
||||
chrome_args.append('--ignore-certificate-errors')
|
||||
if proxy:
|
||||
|
Loading…
x
Reference in New Issue
Block a user