Skip to content

Commit

Permalink
Clear session caches
Browse files Browse the repository at this point in the history
  • Loading branch information
deanishe committed Dec 11, 2017
1 parent bebc1ff commit 85896bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 47 deletions.
3 changes: 3 additions & 0 deletions src/lib/searchio/cmd/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def run(wf, argv):

args = docopt(usage(wf), argv)

# Clear old session data
wf.clear_session_cache()

# Clear entire cache
if args.get('--all'):
return wf.clear_cache()
Expand Down
50 changes: 3 additions & 47 deletions src/lib/searchio/cmd/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,53 +42,6 @@ def usage(wf):
return __doc__


# def do_import_search(wf, url):
# """Parse URL for OpenSearch config."""
# from workflow import web
# from searchio import opensearch

# ctx = Context(wf)
# ICON_ERROR = ctx.icon('error')
# ICON_IMPORT = ctx.icon('import')
# error = None

# if error:
# wf.add_item(error, icon=ICON_ERROR)
# wf.send_feedback()
# return

# icon = wf.workflowfile('icons/icon.png')
# item_icon = ICON_IMPORT
# if search.icon_url:
# log.info('fetching search icon ...')
# p = wf.datafile('icons/{}.png'.format(search.uid))
# try:
# r = web.get(search.icon_url)
# r.raise_for_status()
# except Exception as err:
# log.error('error fetching icon (%s): %r', search.icon_url, err)
# else:
# r.save_to_path(p)
# icon = p
# item_icon = p

# it = wf.add_item(u'Add "{}"'.format(search.name),
# u'↩ to add search',
# valid=True,
# icon=item_icon)

# it.setvar('engine', 'OpenSearch')
# it.setvar('uid', search.uid)
# it.setvar('title', search.name)
# it.setvar('name', search.name)
# it.setvar('icon', icon)
# # it.setvar('jsonpath', search.jsonpath)
# it.setvar('search_url', search.search_url)
# it.setvar('suggest_url', search.suggest_url)

# wf.send_feedback()


def import_search(wf, url):
"""Fetch a search from URL."""
log.info('[fetch] importing "%s" ...', url)
Expand Down Expand Up @@ -138,6 +91,9 @@ def run(wf, argv):
args = docopt(usage(wf), argv)
error = search = None
url = args.get('<url>')
# Clear old cache data
wf.clear_session_cache()

search, error = import_search(wf, url)
data = dict(error=error, search=search)
wf.cache_data('import', data, session=True)

0 comments on commit 85896bf

Please sign in to comment.