From 3a8a88972fd0d27c3568071654f4eeead0ebcfac Mon Sep 17 00:00:00 2001 From: Andreas Date: Fri, 29 Nov 2013 13:59:48 +0100 Subject: [PATCH] Calculate chunkcount with the real file size, not the size saved in the database (might be wrong and results in corrupted download). (cherry picked from commit 42d9a86ff09a42d0a70615e1fd7abe32d645c237) --- src/networkremote/outgoingdatacreator.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/networkremote/outgoingdatacreator.cpp b/src/networkremote/outgoingdatacreator.cpp index bf9884460..a4ef55c1c 100644 --- a/src/networkremote/outgoingdatacreator.cpp +++ b/src/networkremote/outgoingdatacreator.cpp @@ -628,10 +628,6 @@ void OutgoingDataCreator::SendSingleSong(RemoteClient* client, const Song &song, if (!(song.url().scheme() == "file")) return; - // Calculate the number of chunks - int chunk_count = qRound((song.filesize() / kFileChunkSize) + 0.5); - int chunk_number = 1; - // Open the file QFile file(song.url().toLocalFile()); file.open(QIODevice::ReadOnly); @@ -643,6 +639,10 @@ void OutgoingDataCreator::SendSingleSong(RemoteClient* client, const Song &song, QImage null_image; + // Calculate the number of chunks + int chunk_count = qRound((file.size() / kFileChunkSize) + 0.5); + int chunk_number = 1; + while (!file.atEnd()) { // Read file chunk data = file.read(kFileChunkSize);