Comments (4)
I'm generally against the idea of creating cron jobs and/or launch agents from workflows for a couple of reasons:
- There's no reliable way to remove them when a workflow is uninstalled or deactivated.
- A user might turn on workflow syncing in Alfred, which would move all the workflows to somewhere in
~/Dropbox
and break any launch agents/cron jobs you'd installed.
I see the first issue as being particularly problematic for deactivated workflows. For example, I have pretty much every Pinboard.in workflow available installed, but all but 2 are deactivated. If they were all running cron jobs, however, I'd be hammering the Pinboard API and liable to get throttled/banned. AFAIK, there's no simple way for a workflow to tell if it's active/inactive. For this reason, I prefer launching background scripts when the workflow is run to maintain the cache.
The second issue makes a reliable implementation a fairly tricky proposition. As such, I'd prefer to wait and see if there's a lot of demand for it.
While a first_run
flag is something we've talked about, it hasn't been implemented yet.
A more configurable way to clean the cache might be a good idea to include. As with any other feature, it is to my mind mostly a question of how many people would find it useful.
I think adding clean_cache()
alongside clear_cache()
would be confusing, however: the difference is not at all obvious. I'm also not a big fan of having both include
and exclude
arguments: the semantics of how they interact is non-obvious.
My preferred implementation would be to add an optional filter
argument to the existing Workflow.clear_cache()
method that would take a function. The function would be passed each filename and return True
if that cache item should be deleted.
Admittedly, that would require more coding from the workflow author, but would also provide more flexibility.
from alfred-workflow.
I didn't know the clear_cache()
. Having two similar function is a bad idea and I think about your suggestion and using filter
function shall be a better one. I can do the implementation in the next couple days.
For automatically calling the clear_cache()
. I don't like cron
neither but just list it as an option. For the flag option, We can put it as Features to Consider
same as first-run()
.
from alfred-workflow.
Yeah, Workflow.clear_cache()
is the underlying function of the workflow:delcache
magic argument, which is primarily intended for debugging purposes/resetting the workflow (it deletes everything in the cache directory).
It's not explicitly mentioned in the User Manual.
No reason it can't be called by a workflow itself, though, and I think adding an optional argument to allow finer-grained cache deletion wouldn't overly complicate the API.
Really not a fan of cron jobs, though. Launch agents would be a much better solution to the same problem (no need for a complicated crontab parser), and the agent(s) could be named after the bundle ID, making managing them far easier.
from alfred-workflow.
Featured added in PR #49
from alfred-workflow.
Related Issues (20)
- Run with error HOT 2
- Cache Image HOT 5
- Basic auth HOT 3
- Pass parameter to subprocess HOT 5
- Tutorial options for keywords need to be updated for Alfred 4 HOT 11
- set_config raises error when the bundle id is null HOT 4
- Setting only arg on Variables adds line break HOT 1
- will it support python3? HOT 1
- python3 has no cpickle HOT 1
- cant get output HOT 11
- chr() arg not in range(256) error when trying to use Beautiful Soup 4 HOT 1
- workflow:magic not working?
- API functionality question
- AlertCautionIcon.icns does not exist on Big Sur
- ERROR: [Script Filter] JSON error
- Google SDK
- Can't get Script Filter to find the pinboard.py file from the tutorial HOT 1
- [Feature request] Possible to open bookmarks from root?
- Not working on the latest MacOS 12.3 HOT 11
- How to fetch chrome cookie?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alfred-workflow.