Skip to content

Commit

Permalink
Merge pull request #53 from tobozo/1.1.4
Browse files Browse the repository at this point in the history
1.1.4
  • Loading branch information
tobozo authored Jan 2, 2022
2 parents b3a89c0 + 479ee68 commit 737c73b
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 76 deletions.
50 changes: 47 additions & 3 deletions examples/Test_tar_gz_tgz/Test_tar_gz_tgz.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
\*/
// Set **destination** filesystem by uncommenting one of these:
//#define DEST_FS_USES_SPIFFS // WARN: SPIFFS is full of bugs
#define DEST_FS_USES_LITTLEFS
//#define DEST_FS_USES_SD
//#define DEST_FS_USES_LITTLEFS
#define DEST_FS_USES_SD
//#define DEST_FS_USES_FFAT // ESP32 only
//#define DEST_FS_USES_SD_MMC // ESP32 only
//#define DEST_FS_USES_PSRAMFS // ESP32 only
Expand Down Expand Up @@ -80,6 +80,47 @@ bool test_tarExpander()
}


// Test #1: tarExpander()
// Requires: tar file
bool test_tarStreamExpander()
{
bool ret = false;
const char* tarFilePath = "/tar_example.tar";
myPackage.folder = "/tmp"; // for md5 tests

SerialPrintCentered("Testing tarExpander", false, true );

TarUnpacker *TARUnpacker = new TarUnpacker();

TARUnpacker->haltOnError( true ); // stop on fail (manual restart/reset required)

#if defined ESP32
TARUnpacker->setTarVerify( true ); // true = enables health checks but slows down the overall process
#endif
#if defined ESP8266
TARUnpacker->setTarVerify( false ); // true = enables health checks but slows down the overall process
#endif

TARUnpacker->setupFSCallbacks( targzTotalBytesFn, targzFreeBytesFn ); // prevent the partition from exploding, recommended
//TARUnpacker->setLoggerCallback( BaseUnpacker::targzPrintLoggerCallback ); // log verbosity
TARUnpacker->setTarProgressCallback( BaseUnpacker::defaultProgressCallback ); // prints the untarring progress for each individual file
TARUnpacker->setTarStatusProgressCallback( BaseUnpacker::defaultTarStatusProgressCallback ); // print the filenames as they're expanded
TARUnpacker->setTarMessageCallback( myTarMessageCallback/*BaseUnpacker::targzPrintLoggerCallback*/ ); // tar log verbosity

File tarFile = sourceFS.open( tarFilePath, "r" );

if( !TARUnpacker->tarStreamExpander((Stream*)&tarFile, tarFile.size(), tarGzFS, myPackage.folder ) ) {
Serial.println( OpenLine );
SerialPrintfCentered("tarStreamExpander failed with return code #%d", TARUnpacker->tarGzGetError() );
Serial.println( CloseLine );
} else {
ret = true;
}
return ret;
}




// Test #2: gzExpander()
// Requires: gzipped file, filename ends with ".gz"
Expand Down Expand Up @@ -416,6 +457,9 @@ void setup()
{
Serial.begin( 115200 );
EEPROM.begin(512);
#if defined DEST_FS_USES_SD
//SD.begin( 4 );
#endif

#ifdef ESP8266
// WTF on ESP8266 you must include <user_interface.h> and load WiFi in order not to use WiFi :-(
Expand Down Expand Up @@ -483,7 +527,7 @@ void setup()

switch( testNum )
{
case 0: test_succeeded = test_tarExpander(); break;
case 0: test_succeeded = test_tarExpander() && test_tarStreamExpander(); break;
case 1: test_succeeded = test_gzExpander() /*&& test_gzStreamExpander()*/; break;
case 2: test_succeeded = test_tarGzExpander(); break;
case 3: test_succeeded = test_tarGzExpander_no_intermediate(); break;
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ESP32-targz
version=1.1.3
version=1.1.4
author=tobozo <[email protected]>
maintainer=tobozo <[email protected]>
sentence=A library to unpack/uncompress tar, gz, and tar.gz files on ESP32 and ESP8266
Expand Down
Loading

0 comments on commit 737c73b

Please sign in to comment.