-1

I am working on OpenRGB's auto Updates but recently it(Qt) started added extra bytes to the raw file

I am downloading the file with

QByteArray OpenRGBUpdateInfoPage::GetPageSourceOrFile(QString link)
{
    QEventLoop GetPageSourceOrFile;
    QNetworkAccessManager Manager;
    QNetworkRequest RequestSourceOrFile((QUrl(link)));
    QNetworkReply *Reply = Manager.get(RequestSourceOrFile);
    connect(Reply, &QNetworkReply::finished, &GetPageSourceOrFile, &QEventLoop::quit);
    GetPageSourceOrFile.exec();
    QByteArray ReturnInput = Reply->readAll();
    //GetPageSourceOrFile.deleteLater();

    return ReturnInput;
}

and

    QFile ORGBfile(FileStorageLocation);
    ORGBfile.open(QIODevice::WriteOnly);
    QDataStream out(&ORGBfile);
    out << AppBuffer;
    ORGBfile.close();

for writing out to the file

for some reason this issue only occurs on linux

https://gitlab.com/herosilas12/OpenRGB/-/tree/auto-update is the repo

  • 1
    What are the extra 4 bytes? – Tumbleweed53 Dec 04 '20 at 18:41
  • Is the file 4 bytes larger than the `QByteArray` or does the `QByteArray` have 4 extra bytes? – Retired Ninja Dec 04 '20 at 18:43
  • 1
    You appear to be encoding the file contents to a `QByteArray` using a `QDataStream`. If that's the case then you must also *decode* using a `QDataStream`. – G.M. Dec 04 '20 at 18:57
  • Decode what? The QByteArray? Why would that make it work if it was previously working just fine? – CoffeeIsLife Dec 04 '20 at 19:01
  • 3
    What's `AppBuffer`? `QDataStream` isn't like `std::ostream`: generally speaking it encodes the data types written to it with extra metadata that will be used when the stream is subsequently decoded. So if you write a `QByteArray` it might be prefixed by, e.g., a type id and byte size. Having said that, it would be better if you could present a more complete code example -- preferably a [mcve]. – G.M. Dec 04 '20 at 19:40

1 Answers1

1

It turned out that QFile.write() worked.

AppBuffer Was was the downloaded appimage file (In the desc I mentioned that I was working on auto Updates for OpenRGB)

The issue was that QDataStream adds a size header to the front