Progress
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
*.exe
|
*.exe
|
||||||
*.out
|
*.out
|
||||||
|
chunk_server_data_*
|
||||||
|
|||||||
+4
-2
@@ -76,8 +76,8 @@ static void append_hex_as_str(char *out, SHA256 hash)
|
|||||||
{
|
{
|
||||||
char table[] = "0123456789abcdef";
|
char table[] = "0123456789abcdef";
|
||||||
for (int i = 0; i < (int) sizeof(hash); i++) {
|
for (int i = 0; i < (int) sizeof(hash); i++) {
|
||||||
out[(i << 1) + 0] = table[hash.data[i] >> 4];
|
out[(i << 1) + 0] = table[(uint8_t) hash.data[i] >> 4];
|
||||||
out[(i << 1) + 1] = table[hash.data[i] & 0xF];
|
out[(i << 1) + 1] = table[(uint8_t) hash.data[i] & 0xF];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -699,6 +699,8 @@ process_client_upload_chunk(ChunkServer *state, int conn_idx, ByteView msg)
|
|||||||
ByteQueue *output = tcp_output_buffer(&state->tcp, conn_idx);
|
ByteQueue *output = tcp_output_buffer(&state->tcp, conn_idx);
|
||||||
message_writer_init(&writer, output, MESSAGE_TYPE_UPLOAD_CHUNK_SUCCESS);
|
message_writer_init(&writer, output, MESSAGE_TYPE_UPLOAD_CHUNK_SUCCESS);
|
||||||
|
|
||||||
|
message_write(&writer, &new_hash, sizeof(new_hash));
|
||||||
|
|
||||||
if (!message_writer_free(&writer))
|
if (!message_writer_free(&writer))
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
+13
-6
@@ -1534,22 +1534,29 @@ static void process_event_for_write(TinyDFS *tdfs,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SHA256 hash;
|
||||||
|
uint16_t expected_type;
|
||||||
|
if (tdfs->operations[opidx].uploads[found].chunk_index >= tdfs->operations[opidx].num_hashes)
|
||||||
|
expected_type = MESSAGE_TYPE_CREATE_CHUNK_SUCCESS;
|
||||||
|
else {
|
||||||
|
expected_type = MESSAGE_TYPE_UPLOAD_CHUNK_SUCCESS;
|
||||||
|
|
||||||
|
if (!binary_read(&reader, &hash, sizeof(hash))) {
|
||||||
|
// TODO
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Check that there is nothing else to read
|
// Check that there is nothing else to read
|
||||||
if (binary_read(&reader, NULL, 1)) {
|
if (binary_read(&reader, NULL, 1)) {
|
||||||
// TODO
|
// TODO
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t expected_type;
|
|
||||||
if (tdfs->operations[opidx].uploads[found].chunk_index >= tdfs->operations[opidx].num_hashes)
|
|
||||||
expected_type = MESSAGE_TYPE_CREATE_CHUNK_SUCCESS;
|
|
||||||
else
|
|
||||||
expected_type = MESSAGE_TYPE_UPLOAD_CHUNK_SUCCESS;
|
|
||||||
|
|
||||||
if (type != expected_type) {
|
if (type != expected_type) {
|
||||||
tdfs->operations[opidx].uploads[found].status = UPLOAD_FAILED;
|
tdfs->operations[opidx].uploads[found].status = UPLOAD_FAILED;
|
||||||
} else {
|
} else {
|
||||||
tdfs->operations[opidx].uploads[found].status = UPLOAD_COMPLETED;
|
tdfs->operations[opidx].uploads[found].status = UPLOAD_COMPLETED;
|
||||||
|
tdfs->operations[opidx].uploads[found].final_hash = hash;
|
||||||
for (int i = 0; i < tdfs->operations[opidx].num_uploads; i++) {
|
for (int i = 0; i < tdfs->operations[opidx].num_uploads; i++) {
|
||||||
|
|
||||||
if (tdfs->operations[opidx].uploads[i].status == UPLOAD_WAITING
|
if (tdfs->operations[opidx].uploads[i].status == UPLOAD_WAITING
|
||||||
|
|||||||
+4
-1
@@ -1590,7 +1590,10 @@ int mock_fstat(int fd, struct stat *buf)
|
|||||||
|
|
||||||
int mock_mkstemp(char *path)
|
int mock_mkstemp(char *path)
|
||||||
{
|
{
|
||||||
return mkstemp(path);
|
int fd = mkstemp(path);
|
||||||
|
if (fd < 0) return fd;
|
||||||
|
|
||||||
|
return wrap_native_file_into_desc(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* mock_realpath(char *path, char *dst)
|
char* mock_realpath(char *path, char *dst)
|
||||||
|
|||||||
Reference in New Issue
Block a user