Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'cache_dir' is not defined #1104

Closed
Groxx opened this issue Sep 8, 2024 · 2 comments
Closed

'cache_dir' is not defined #1104

Groxx opened this issue Sep 8, 2024 · 2 comments

Comments

@Groxx
Copy link

Groxx commented Sep 8, 2024

It's fairly likely that this is due to me mucking some config up, but the error looks like it's caused by incorrect code:

calibre, version 7.17.0
ERROR: Unhandled exception: <b>NameError</b>:name 'cache_dir' is not defined

calibre 7.17  embedded-python: True
Linux-6.8.0-41-generic-x86_64-with-glibc2.39 Linux ('64bit', 'ELF')
('Linux', '6.8.0-41-generic', '#41-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug  2 20:41:06 UTC 2024')
Python 3.11.5
Interface language: None
EXE path: /opt/calibre/bin/calibre
Successfully initialized third party plugins: FanFicFare (4, 38, 0) && KOReader Sync (0, 6, 7) && Reading List (1, 15, 4) && Standard Ebooks (1, 0, 0)
Traceback (most recent call last):
  File "calibre_plugins.fanficfare_plugin.fff_plugin", line 689, in get_urls_from_page_menu
    frompage = self.get_urls_from_page(url)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "calibre_plugins.fanficfare_plugin.fff_plugin", line 712, in get_urls_from_page
    return get_urls_from_page(url,configuration)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/groxx/.config/calibre/plugins/FanFicFare.zip/fanficfare/geturls.py", line 44, in get_urls_from_page
    return adapter.get_urls_from_page(url,normalize)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/groxx/.config/calibre/plugins/FanFicFare.zip/fanficfare/adapters/base_adapter.py", line 477, in get_urls_from_page
    data = self.get_request(url,usecache=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/groxx/.config/calibre/plugins/FanFicFare.zip/fanficfare/requestable.py", line 119, in get_request
    return self.get_request_redirected(url,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/groxx/.config/calibre/plugins/FanFicFare.zip/fanficfare/requestable.py", line 111, in get_request_redirected
    (data,rurl) = self.configuration.get_fetcher().get_request_redirected(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/groxx/.config/calibre/plugins/FanFicFare.zip/fanficfare/configurable.py", line 1089, in get_fetcher
    self.browser_cache = BrowserCache(self.getConfig,
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/groxx/.config/calibre/plugins/FanFicFare.zip/fanficfare/browsercache/__init__.py", line 44, in __init__
    os.path.abspath(cache_dir))
                    ^^^^^^^^^
NameError: name 'cache_dir' is not defined

This is referring to the exception branch here:

def __init__(self, getConfig_fn, getConfigList_fn):
"""Constructor for BrowserCache"""
# import of child classes have to be inside the def to avoid circular import error
for browser_cache_class in [SimpleCache, BlockfileCache, FirefoxCache2]:
self.browser_cache_impl = browser_cache_class.new_browser_cache(getConfig_fn,
getConfigList_fn)
if self.browser_cache_impl is not None:
break
if self.browser_cache_impl is None:
raise BrowserCacheException("Directory does not contain a known browser cache type: '%s'"%
os.path.abspath(cache_dir))

which doesn't have a defined cache_dir variable, nor do I see any globals in the module that it could be referencing....

...though it has been a while since I've done any Python, so apologies if I've missed something obvious.

@JimmXinu
Copy link
Owner

JimmXinu commented Sep 8, 2024

Apparently I didn't test turning on use_browser_cache:true without setting browser_cache_path when I made change 478d2e8.

@Groxx
Copy link
Author

Groxx commented Sep 8, 2024

Thank you!

This was apparently due to me using librewolf, which does not write caches to disk by default. (you can enable that in about:config, browser.cache.disk.enable -> change to true)

I'm now getting gio-launch-desktop errors instead, but it is reading the cache, and if I visit the URLs printed to calibre-debug it populates and reads the data. I'm still exploring the gio-launch-desktop thing but it looks like it's probably coming from Calibre, and probably not something that should be used in the first place (e.g. xdg-open is probably better)....

... but I'm probably gonna stop digging here tbh, unless anyone's particularly interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants