diff --git a/src/member_files/transfer.c b/src/member_files/transfer.c index 25130c06..6d898c11 100644 --- a/src/member_files/transfer.c +++ b/src/member_files/transfer.c @@ -360,7 +360,7 @@ static void transfer_response(void* arg, const struct mf_message* r) { static void transfer_send_open(struct mf_transfer* t, uint8_t command) { struct mf_message q = transfer_packet(t, command); q.request_id = 0; q.cursor = command == MF_STAT ? 0 : t->request.id; - if (command == MF_STREAM_WRITE) memcpy(q.version, t->request.version, 16); + if (command == MF_STREAM_WRITE || command == MF_STAT) memcpy(q.version, t->request.version, 16); t->pending = member_files_request(t->files->inst, t->request.group, t->request.server, &q, transfer_response, t); if (!t->pending) transfer_stop(t, MF_BUSY); } diff --git a/tests/test_member_files_network.c b/tests/test_member_files_network.c index 5e652055..8daa9398 100644 --- a/tests/test_member_files_network.c +++ b/tests/test_member_files_network.c @@ -92,6 +92,7 @@ static void api_start(struct network_test* t, unsigned index, int node, int uplo .server = t->ids[SERVER], .owner = t->ids[upload ? node : AUTHOR], .upload = upload }; snprintf(q.remote, sizeof(q.remote), "%s", remote); snprintf(q.local, sizeof(q.local), "%s", upload ? source : c->local); + if (!upload && source) memcpy(q.version, source, 16); c->handle = member_files_transfer_start(&q, api_event, c); if (!c->handle) fail(t, "parallel API start"); } @@ -262,6 +263,13 @@ static void tick(void* arg) { if (!t->api[0].finished || !t->api[1].finished || !t->api[7].finished) goto again; if (t->api[0].status || t->api[1].status || t->api[7].status || !check_file(t->api[0].local, BYTES) || !check_file(t->api[1].local, BYTES) || !check_file(t->api[7].local, 0)) { fail(t, "parallel/empty download bytes"); return; } + t->phase = 22; + uint8_t stale[16]; memset(stale, 0xa5, sizeof(stale)); + api_start(t, 7, READER, 0, "file.bin", (const char*)stale); + } else if (t->phase == 22 && t->api[7].finished) { + if (t->api[7].status != MF_STALE || !check_file(t->api[7].local, 0)) { + fail(t, "stale download changed existing destination"); return; + } t->phase = 10; t->answered = 0; struct mf_message q = { .command = MF_STAT, .owner = t->ids[AUTHOR] }; snprintf(q.path, sizeof(q.path), "cancelled.bin"); if (!member_files_request(t->nodes[READER], GROUP, t->ids[SERVER], &q, response, t)) { fail(t, "cancelled STAT"); return; }