learningequality / ka-lite

KA Lite: lightweight web server for serving core Khan Academy content (videos and exercises) without needing internet connectivity
https://learningequality.org/ka-lite/
Other
457 stars 303 forks source link

Deleting videos through Update page causes error when cache is disabled #571

Closed jamalex closed 11 years ago

jamalex commented 11 years ago

When the cache is disabled (CACHE_TIME = 0), selecting videos from the topic tree on the Update tab and clicking "Delete selected videos" returns the following error: image

This seems to be because invalidate_all_pages_related_to_video calls filter(has_cache_key, all_paths), and has_cache_key calls get_web_cache().has_key, which throws the error if there's no cache.

There are probably other cache functions that also assume the existence of the cache. It might be better to either have get_web_cache() return a dummy object with nullop methods, or check for its existence and exit early if there's no cache.

This isn't a priority, since caching should always be enabled in production, but would be good to make more robust. (I just happened to have caching disabled because I was testing template changes).

bcipolli commented 11 years ago

Nice catch. There are places it gets checked (videodownload, videoscan) before calling those functions, but probably best to push those checks into the actual function, as you say.

I believe it should still delete the files (and the objects), if I remember correctly.

bcipolli commented 11 years ago

I fixed this recently, and merged to release-0.10. Should be fixed in 0.10.2