Skip to content

Commit

Permalink
Fix compatibility with Tar specification
Browse files Browse the repository at this point in the history
IB-7877

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Nov 8, 2023
1 parent d5bbd75 commit 741dc40
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions client/CDoc2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace cdoc20 {
return true;
return dispatchToMain([] {
auto *notification = new FadeInNotification(Application::mainWindow(),
ria::qdigidoc4::colors::WHITE, ria::qdigidoc4::colors::MANTIS, 110);
ria::qdigidoc4::colors::WHITE, ria::qdigidoc4::colors::MANTIS, 110);
notification->start(QCoreApplication::translate("MainWindow", "Check internet connection"), 750, 3000, 1200);
return false;
});
Expand Down Expand Up @@ -206,7 +206,7 @@ namespace cdoc20 {
return io->write(pad) == pad.size();
};
auto toPaxRecord = [](const QByteArray &keyword, const QByteArray &value) {
QByteArray record = " " + keyword + "=" + value + "\n";
QByteArray record = ' ' + keyword + '=' + value + '\n';
QByteArray result;
for(auto len = record.size(); result.size() != len; ++len)
result = QByteArray::number(len + 1) + record;
Expand Down Expand Up @@ -242,19 +242,23 @@ namespace cdoc20 {
return false;
}
Header eof{};
return io->write((const char*)&eof, Header::Size) == Header::Size;
return io->write((const char*)&eof, Header::Size) == Header::Size &&
io->write((const char*)&eof, Header::Size) == Header::Size;
}

std::vector<CDoc::File> files(bool &warning) const
{
std::vector<CDoc::File> result;
Header h {};
auto readHeader = [&h, this] { return io->read((char*)&h, Header::Size) == Header::Size; };
while(io->bytesAvailable() > 0)
{
if(io->read((char*)&h, Header::Size) != Header::Size)
if(!readHeader())
return {};
if(h.isNull())
{
if(!readHeader() && !h.isNull())
return {};
warning = io->bytesAvailable() > 0;
return result;
}
Expand All @@ -270,7 +274,7 @@ namespace cdoc20 {
if(paxData.size() != f.size)
return {};
io->skip(padding(f.size));
if(io->read((char*)&h, Header::Size) != Header::Size || h.isNull() || !h.verify())
if(!readHeader() || h.isNull() || !h.verify())
return {};
f.size = fromOctal(h.size);
for(const QByteArray &data: paxData.split('\n'))
Expand Down

0 comments on commit 741dc40

Please sign in to comment.