Parchive / par2cmdline

Official repo for par2cmdline and libpar2
http://parchive.sourceforge.net
GNU General Public License v2.0
723 stars 75 forks source link

[Feature request / par2create] Option to regenerate par2 files *if input file changed* #170

Open ronjouch opened 2 years ago

ronjouch commented 2 years ago

I'm looking at using par2 on 7z archive files as an alternative to RAR's “recovery record”.

Unlike use cases I often see here on immutable data (e.g. photos, videos), the archives I want to protect are mutable and change frequently. Said differently: if using WinRAR with its “recovery record” option, updating the recovery record on archive change is automatically done by WinRAR (it’s “integrated”), but in par2-land to my knowledge there is no such automation when an par2-protected file is mutated, calling for an update of the par2 file. And so,

→ I'd like to tell par2create to “scrap existing par2 files and regenerate them, if the input file changed”. The word “changed" in the previous sentence would mean one of:

  1. Input file was more recently modified than the par2 files
  2. ... or Input file size/checksum changed. Obvious caveat: corruption of checksum will mean an undesirable PAR2 scrap & re-create, so I'm not sure this 2. is such a great idea.

It could look like an extra -u : Update / regenerate PAR2 archive if input file changed , and on invoking par2create -u myfile.foo, it could look like:

If the input file was changed / is no longer properly protected by the .par2:

Running with option "-u", will update PAR2 files as needed.
- Detected myfile.foo as more recent than myfile.foo.par2 , regenerating par2...
  Successfully regenerated myfile.foo.par2
Done updating PAR2 files, 1 PAR file(s) touched.

And if the .par2 file remains the most recent,

Running with option "-u", will update PAR2 files as needed.
No input file needed a PAR2 update, all PAR2 left untouched.

Alternatives

I guess I could do the same with a bit of scripting, but it'd be nice to have a built-in option.

Or is there a way to get the same end-result with existing options, but I missed it?

Thanks for par2.