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 denylist writing functionality #10

Open
mcamou opened this issue Jul 3, 2023 · 4 comments
Open

Add denylist writing functionality #10

mcamou opened this issue Jul 3, 2023 · 4 comments

Comments

@mcamou
Copy link

mcamou commented Jul 3, 2023

As it stands, the NoPFS library only supports reading the denylist format, but doesn't have any support for writing the denylist to a file. While most applications will only be reading the denylist, there are some that will need to write. It would be best to have both functionalities in the same library, to ensure correct round-tripping.

@hsanjuan
Copy link
Collaborator

hsanjuan commented Jul 5, 2023

Given the denylist is plaintext and writing is mostly appending lines to a file, is there anything special that you would expect from this functionality?

I'm thinking:

  • Given a CID, generate a multhash rule
  • Given a CID or domain, + path, generate a multihash-double-hash rule
  • ...

@mcamou
Copy link
Author

mcamou commented Jul 5, 2023

For my current purposes, I'd just like to have a denylist.Write(filename string) function which would overwrite the given file with the current denylist. ATM it's just writing the appropriate header and then looping through the Entries slice and writing RawValue, but it would make it simpler and would also help if we later e.g. add other header fields.

Although the conversions that you mention were not what I was originally thinking of, they would also be REALLY nice, generating different types of rules given CIDs, domains, etc. I had to do a bit of reverse-engineering and I'm still not 100% sure that what I did is correct (currently testing).

If we agree that this belongs here I could make a couple of PRs to add both the write functionality and one or two of the functions, and take it from there.

@hsanjuan
Copy link
Collaborator

I'd just like to have a denylist.Write(filename string)

How is this different from f := os.Open("path", APPEND); f.Write("/ipfs/cid\n") ?

@hsanjuan
Copy link
Collaborator

(or just copying the original file).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants