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

Add update button for adnauseam.txt only #752

Closed
dhowe opened this issue Jan 11, 2017 · 8 comments
Closed

Add update button for adnauseam.txt only #752

dhowe opened this issue Jan 11, 2017 · 8 comments

Comments

@dhowe
Copy link
Owner

dhowe commented Jan 11, 2017

we need a quick way for ourselves and users to quickly update this one list to the version in uAssets on github

@cqx931
Copy link
Collaborator

cqx931 commented Jan 17, 2017

I have tried to figure out what happens when user clicks "update now" button and this is the process that I understand:
The whole process consist of two parts, asset updating and reload local filter lists.
1.Asset updating
This part happens in assets.js µBlock.assetUpdater and is for all 3rd party filter lists. It will try to download a new version online and update the latest version in the cache.

2.Reload local filter lists
This part is in storage.js, µB.getCompiledFilterList and is for filters in the 'filters' folder in uAsset. adnauseam.txt is also one of them.
So when all the remote asset are updated, adnauseam will reload all other local filter lists.

If we want to achieve the feature that we talked about yesterday (update adnauseam.txt from github server), I think we need to move the file from 'filters' folder to 'thirdparties' and configure the remote link in filter-lists.json. So that it can follows the mechanism of all other third party filters and be updated from remote.

So currently it seems to me that adnauseam.txt will only get updated from a new release for ordinary users.

Please correct me if I am wrong.

@dhowe
Copy link
Owner Author

dhowe commented Jan 17, 2017

I don't think this is correct... adnauseam.txt is fetched from Github when it is marked as being different than what is on there:

screen shot 2017-01-17 at 7 13 11 pm

so we need to figure out where the check is done when the 'new version available' label is added, and then do that same check ourselves when the 'update' button is pressed; then if a new-version is there, download it and update the cache

@dhowe
Copy link
Owner Author

dhowe commented Jan 17, 2017

@cqx931 -- note also this important PR: gorhill#2314

makes me think we should wait until post-merge before working further on this further -- your thoughts?

@cqx931
Copy link
Collaborator

cqx931 commented Jan 18, 2017

yes, agreed.
I am glad to see that they don't use checksum anymore...

@dhowe
Copy link
Owner Author

dhowe commented Jan 18, 2017

blocked on merge ticket

@gorhill
Copy link

gorhill commented Jan 19, 2017

With the new code, there are two way you may want to do this:

  1. Create and host your own assets/assets.json, which would contains an entry for your adnauseam.txt asset. The entry should have the following fields:
"adnauseam.txt": {
  "content": "[whatever you want]",
  "contentURL": [ array of URLs of where to fetch the resource ],
  "updateAfter": 2
}

If you use this approach, you will have to modify the "assets.json" entry to point to your location for update purpose.

  1. Use uBO's own assets.json, but register programmatically the entry at startup time for your adnauseam.txt asset.
µBlock.assets.registerAssetSource('adnauseam.txt', {
  content: '[whatever you want]',
  contentURL: [ array of URLs of where to fetch the resource ],
  updateAfter: 2,
  submitter: 'adnauseam'
});

content is just a token for what the content of the resource contains. uBO will look at this when gathering all the filter lists available -- in which case content will be filters (this makes the resource appear in the 3rd-party filters pane). uBO uses internal for resources other than filters.

contentURL can be a URL string or an array of URL strings. This tells the asset source manager where to get the resource. Typically I assume you will ship with a local version of adnauseam.txt, in which case you should list the relative URL in there, and a also provide a URL of where to fetch adnauseam.txt for update purpose.

updateAfter tells the asset updater how often (in days) it should pull the asset from its remote location(s).

The submitter field is needed only if you register the resource programmatically. This tells uBO to not remove the entry when it updates its own assets.json resource.

Calling µBlock.assets.updateStart({...}) will force uBO to launch an update session, i.e. lookup what is obsolete (as per updateAfter) and for assets in need of an update, to pull assets from their remote locations and cache them locally. If auto-update is enabled, the semantic of µBlock.assets.get('adnauseam.txt', ...) is to return the most recent version of the asset, keeping in mind that auto-update kicks in a few minutes after launch.

When an asset is updated, the asset manager fires a notification to observers registered through µBlock.assets.addObserver(callback), and the observer call will be passed the argument topic and details, where topic will be 'after-asset-updated', and details is an object with the properties assetKey (should be 'adnauseam.txt' as per above) and content which is the new content.

@dhowe
Copy link
Owner Author

dhowe commented Jan 19, 2017

@gorhill thanks for this -- super helpful

@dhowe dhowe self-assigned this Jan 19, 2017
@dhowe dhowe modified the milestones: Release 3.2, Release 3.3 Mar 2, 2017
@cqx931
Copy link
Collaborator

cqx931 commented Mar 15, 2017

I have added an update button based on the new asset.
Please check.
#929

@cqx931 cqx931 closed this as completed Mar 21, 2017
This was referenced Mar 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants