Allow sending data after file is paused.

Dissallow sending non requested data.
This commit is contained in:
irungentoo 2015-06-30 22:05:40 -04:00
parent 97d6c4ba18
commit a377f55b3d
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98

View File

@ -1329,9 +1329,6 @@ int file_data(const Messenger *m, int32_t friendnumber, uint32_t filenumber, uin
if (ft->status != FILESTATUS_TRANSFERRING) if (ft->status != FILESTATUS_TRANSFERRING)
return -4; return -4;
if (ft->paused != FILE_PAUSE_NOT)
return -4;
if (length > MAX_FILE_DATA_SIZE) if (length > MAX_FILE_DATA_SIZE)
return -5; return -5;
@ -1343,7 +1340,7 @@ int file_data(const Messenger *m, int32_t friendnumber, uint32_t filenumber, uin
return -5; return -5;
} }
if (position != ft->transferred) { if (position != ft->transferred || (ft->requested <= position && ft->size != 0)) {
return -7; return -7;
} }
@ -1469,11 +1466,12 @@ static void do_reqchunk_filecb(Messenger *m, int32_t friendnumber)
++ft->slots_allocated; ++ft->slots_allocated;
if (m->file_reqchunk) uint64_t position = ft->requested;
(*m->file_reqchunk)(m, friendnumber, i, ft->requested, length, m->file_reqchunk_userdata);
ft->requested += length; ft->requested += length;
if (m->file_reqchunk)
(*m->file_reqchunk)(m, friendnumber, i, position, length, m->file_reqchunk_userdata);
--free_slots; --free_slots;
} }