Network remote: send md5 hash along with library and files.

This commit is contained in:
Andreas 2013-12-31 15:26:42 +01:00
parent 94ccd325d7
commit 8ff0692809
2 changed files with 15 additions and 1 deletions

View File

@ -257,6 +257,7 @@ message ResponseSongFileChunk {
optional SongMetadata song_metadata = 6; // only sent with first chunk!
optional bytes data = 7;
optional int32 size = 8;
optional bytes file_hash = 9;
}
message ResponseLibraryChunk {
@ -264,6 +265,7 @@ message ResponseLibraryChunk {
optional int32 chunk_count = 2;
optional bytes data = 3;
optional int32 size = 4;
optional bytes file_hash = 5;
}
message ResponseSongOffer {
@ -276,7 +278,7 @@ message RequestRateSong {
// The message itself
message Message {
optional int32 version = 1 [default=13];
optional int32 version = 1 [default=14];
optional MsgType type = 2 [default=UNKNOWN]; // What data is in the message?
optional RequestConnect request_connect = 21;

View File

@ -641,6 +641,11 @@ void OutgoingDataCreator::SendSingleSong(RemoteClient* client, const Song &song,
// Open the file
QFile file(song.url().toLocalFile());
// Get md5 for file
QByteArray md5 = Utilities::Md5File(file).toHex();
qLog(Debug) << "md5 for file" << song.url().toLocalFile() << "=" << md5;
file.open(QIODevice::ReadOnly);
QByteArray data;
@ -665,6 +670,7 @@ void OutgoingDataCreator::SendSingleSong(RemoteClient* client, const Song &song,
chunk->set_file_number(song_no);
chunk->set_size(file.size());
chunk->set_data(data.data(), data.size());
chunk->set_file_hash(md5.data(), md5.size());
// On the first chunk send the metadata, so the client knows
// what file it receives.
@ -746,6 +752,11 @@ void OutgoingDataCreator::SendLibrary(RemoteClient *client) {
// Open the file
QFile file(temp_file_name);
// Get the md5 hash
QByteArray md5 = Utilities::Md5File(file).toHex();
qLog(Debug) << "Library md5" << md5;
file.open(QIODevice::ReadOnly);
QByteArray data;
@ -766,6 +777,7 @@ void OutgoingDataCreator::SendLibrary(RemoteClient *client) {
chunk->set_chunk_number(chunk_number);
chunk->set_size(file.size());
chunk->set_data(data.data(), data.size());
chunk->set_file_hash(md5.data(), md5.size());
// Send data directly to the client
client->SendData(&msg);