diff --git a/simgear/io/untar.cxx b/simgear/io/untar.cxx index cc70c62f..4002b61b 100644 --- a/simgear/io/untar.cxx +++ b/simgear/io/untar.cxx @@ -634,7 +634,7 @@ void ArchiveExtractor::extractBytes(const uint8_t* bytes, size_t count) d.reset(new ZipExtractorPrivate(this)); } else { - SG_LOG(SG_IO, SG_ALERT, "Invcalid archive type"); + SG_LOG(SG_IO, SG_ALERT, "Invalid archive type"); _invalidDataType = true; return; } @@ -724,8 +724,10 @@ ArchiveExtractor::DetermineResult ArchiveExtractor::isTarData(const uint8_t* byt } int result = inflate(&z, Z_SYNC_FLUSH); - if (result != Z_OK) { - SG_LOG(SG_IO, SG_WARN, "inflate failed:" << result); + if ((result == Z_OK) || (result == Z_STREAM_END)) { + // all good + } else { + SG_LOG(SG_IO, SG_WARN, "isTarData: Zlib inflate failed:" << result); inflateEnd(&z); return Invalid; // not tar data } diff --git a/simgear/package/CatalogTest.cxx b/simgear/package/CatalogTest.cxx index d901c68f..6dae43f7 100644 --- a/simgear/package/CatalogTest.cxx +++ b/simgear/package/CatalogTest.cxx @@ -60,6 +60,7 @@ std::string readFileIntoString(const SGPath& path) SGPath global_serverFilesRoot; unsigned int global_catalogVersion = 0; bool global_failRequests = false; +bool global_fail747Request = true; class TestPackageChannel : public TestServerChannel { @@ -97,8 +98,12 @@ public: } if (path == "/catalogTest1/b747.tar.gz") { - sendErrorResponse(403, false, "Bad URL"); - return; + if (global_fail747Request) { + sendErrorResponse(403, false, "Bad URL"); + return; + } else { + path = "/catalogTest1/b747.tar.gz"; // valid path + } } localPath.append(path); @@ -1083,7 +1088,8 @@ void updateInvalidToInvalid(HTTP::Client* cl) void testInstallBadPackage(HTTP::Client* cl) { global_catalogVersion = 0; - + global_fail747Request = true; + SGPath rootPath(simgear::Dir::current().path()); rootPath.append("pkg_install_bad_pkg"); simgear::Dir pd(rootPath); @@ -1113,15 +1119,29 @@ void testInstallBadPackage(HTTP::Client* cl) SG_VERIFY(p1->existingInstall() == ins); SG_CHECK_EQUAL(ins->status(), pkg::Delegate::FAIL_DOWNLOAD); SG_CHECK_EQUAL(ins->path(), rootPath / "org.flightgear.test.catalog1" / "Aircraft" / "b744"); -} + + // now retry, it should work + global_fail747Request = false; + + auto ins2 = p1->install(); + SG_CHECK_EQUAL(ins2, p1->existingInstall()); + root->scheduleToUpdate(ins2); + SG_VERIFY(ins2->isQueued()); + didFail = false; + waitForUpdateComplete(cl, root); + SG_VERIFY(p1->isInstalled()); + SG_VERIFY(!didFail); + SG_CHECK_EQUAL(ins->status(), pkg::Delegate::STATUS_SUCCESS); + SG_CHECK_EQUAL(ins->path(), rootPath / "org.flightgear.test.catalog1" / "Aircraft" / "b744"); +} int main(int argc, char* argv[]) { // sglog().setLogLevels( SG_ALL, SG_DEBUG ); HTTP::Client cl; - cl.setMaxConnections(1); + cl.setMaxConnections(1); global_serverFilesRoot = SGPath(SRC_DIR); @@ -1156,7 +1176,7 @@ int main(int argc, char* argv[]) removeInvalidCatalog(&cl); testVersionMigrateToId(&cl); - + testInstallBadPackage(&cl); SG_LOG(SG_GENERAL, SG_INFO, "Successfully passed all tests!"); diff --git a/simgear/package/catalogTest1/b744/b747-400.xml b/simgear/package/catalogTest1/b744/b747-400.xml new file mode 100644 index 00000000..a23281ff --- /dev/null +++ b/simgear/package/catalogTest1/b744/b747-400.xml @@ -0,0 +1,7 @@ + + + + + Boeing 747-400 + + diff --git a/simgear/package/catalogTest1/b747.tar.gz b/simgear/package/catalogTest1/b747.tar.gz new file mode 100644 index 00000000..ed8e6f1c Binary files /dev/null and b/simgear/package/catalogTest1/b747.tar.gz differ diff --git a/simgear/package/catalogTest1/catalog.xml b/simgear/package/catalogTest1/catalog.xml index 4305b1d1..eb975620 100644 --- a/simgear/package/catalogTest1/catalog.xml +++ b/simgear/package/catalogTest1/catalog.xml @@ -215,8 +215,8 @@ 4 - a94ca5704f305b90767f40617d194ed6 - + 4d3f7417d74f811aa20ccc4f35673d20 + http://localhost:2000/catalogTest1/b747.tar.gz