tobozo / ESP32-targz

🗜️ An Arduino library to unpack/uncompress tar, gz, and tar.gz files on ESP32 and ESP8266
Other
118 stars 15 forks source link

Enhancement request: Suggestion for failure behavior #11

Closed scubachristopher closed 3 years ago

scubachristopher commented 3 years ago

Heya @tobozo,

With at least gzUpdater, perhaps you would consider returning an ERROR code instead of void and quieting the error messages, leaving that to the application?

Chasing down something on my end, and when gzUpdater unexpectedly returns (instead of restart) because of error, I have no information in my application I can send to the operator (Cloud):

Attempting to flash
[E][ESP32-targz.cpp:246] gzProcessBlock(): Error uncompressing data
[E][Updater.cpp:264] end(): premature end: res:0, pos:385024/1159168

If that makes sense, awesome. If you want to keep as is, totally fine, I'll just fork.

Happy to do a PR if you agree, but busy moving house starting this AM for a few days. In fact, I'll do the PR if you move me? ;)

Thanks for the consideration

tobozo commented 3 years ago

hey @scubachristopher thanks for your feedback

This totally makes sense, do you have an example of faulty gz file I can test with, or point me to a way I can produce such file by myself ?

[edit] never mind I'm already creating a collection of return values, also found out this is needed by untar.h too :-) [edit2] I won't be quieting all the debug statements because 'info', 'debug' and 'verbose' aren't supposed to be quiet, for quiet mode: set core debug level to 'warn', 'error' or 'none'.

tobozo commented 3 years ago

Thanks again for your inspiring feedback, I just pushed those changes, it's now acting as the Update API, returns false in case of error, and provides tarGzGetError() for debug.

  if( ! gzUpdater(SPIFFS, firmwareFile ) ) {
    Serial.printf("gzUpdater failed with return code #%d", tarGzGetError() );
  }

Happy unzipping in your new house ^^

scubachristopher commented 3 years ago

Looks great! Appreciate it! Sent a few Euros so you can get a coffee (or better yet, a beer) on me ;)

Can you bump the version? For some reason, VS Code still pulls down the old one for me, even after blowing out the .pio directory.

Thanks again man!

tobozo commented 3 years ago

ooh thanks!

bumped the version to 0.2.1 in the Library Manager :-)