albertinad / brackets-bower

Bower integration in Brackets.
MIT License
47 stars 9 forks source link

Problem with "Time to reload Bower registry" setting #82

Open JKVeganAbroad opened 8 years ago

JKVeganAbroad commented 8 years ago

Under Bower Settings » Time to reload the Bower registry (m), you can fill in the number of minutes before the Bower registry cache is refreshed.

I set my value to 10080 (i.e. 168 hours / 7 days).

However, this value doesn't seem to be respected after closing and relaunching Brackets, or perhaps the cache is lost upon closing Brackets.

This is a problem because I like to shutdown my computer every night, and I have a slow internet connection; loading the Bower registry takes a few minutes for me.

Suggestion

Upon launching Brackets, the Bower extension should verify if its Bower registry cache is older than the allowed time lapse specified in the settings. If the cache is within the allowed time, continue using the cache, and don't reload the Bower registry.

albertinad commented 8 years ago

Hi @JKAussieSkater, the time to reload registry settings is valid only when brackets starts, once you the process ends, and start again, the registry will be always reload, no matter the specified time. The cache is in-memory, and it is not intended to be used with such long time. You have a really good point and use case, so this is a good improvement to implement. Thanks!

JKVeganAbroad commented 8 years ago

@albertinad, I was going to have a try at coding this myself!

I'm having trouble trying to identify which file actually retrieves the Bower database.

I had a look here, which at first appeared to be the code which does this. But upon further inspection, it seems like this code actually does the job.

But even then, they seem to depend on PackageManager.js. It's a bit challenging working up the tree of requires trying to figure out the source code for the database retriever!

Would you be able to point me in the right direction to approach this task? I'd really appreciate it!

albertinad commented 8 years ago

Hi @JKAussieSkater, thanks!! I'm planning to remove QuickInstall functionality in favor for a better search and filter functionality that will take place in the panel UI. With this change, how the search is done will change also. QuickInstall keeps an in-memory cache for the time defined in the setting, and that keeps in the context of the QuickInstall module. The function that you referenced in your comment is the one that actually makes the queries and keep the result (packages) for a while. For getting the results, I'm just using the Bower search command, searching for the whole registry and keep it. Since you may be using Bower, or something may remain in the Bower cache, before doing that I just do a quick search to the cache in order to display some results to the user so they have something to work while the whole registry is loaded.

In the new design, this will no longer exists, and I will not use bower search command. I will just query the catalog using some APIs provided by other endpoints and the cache that I will keep locally on disk, will be a reduced set of packages.