Progress
This commit is contained in:
+5
-2
@@ -318,8 +318,9 @@ int file_tree_delete_entity(FileTree *ft, string path)
|
||||
}
|
||||
|
||||
int file_tree_write(FileTree *ft, string path,
|
||||
uint64_t off, uint64_t len, SHA256 *prev_hashes,
|
||||
SHA256 *hashes, SHA256 *removed_hashes, int *num_removed)
|
||||
uint64_t off, uint64_t len, uint32_t num_chunks,
|
||||
SHA256 *prev_hashes, SHA256 *hashes,
|
||||
SHA256 *removed_hashes, int *num_removed)
|
||||
{
|
||||
int num_comps;
|
||||
string comps[MAX_COMPS];
|
||||
@@ -341,6 +342,8 @@ int file_tree_write(FileTree *ft, string path,
|
||||
uint64_t first_chunk_index = off / f->chunk_size;
|
||||
uint64_t last_chunk_index = first_chunk_index + (len - 1) / f->chunk_size;
|
||||
|
||||
assert(last_chunk_index - first_chunk_index + 1 == num_chunks);
|
||||
|
||||
if (last_chunk_index >= f->num_chunks) {
|
||||
uint64_t old_num_chunks = f->num_chunks;
|
||||
SHA256 *new_chunks = sys_malloc((last_chunk_index+1) * sizeof(SHA256));
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ bool file_tree_uses_hash(FileTree *ft, SHA256 hash);
|
||||
int file_tree_list(FileTree *ft, string path, ListItem *items, int max_items);
|
||||
int file_tree_create_entity(FileTree *ft, string path, bool is_dir, uint64_t chunk_size);
|
||||
int file_tree_delete_entity(FileTree *ft, string path);
|
||||
int file_tree_write(FileTree *ft, string path, uint64_t off, uint64_t len, SHA256 *prev_hashes, SHA256 *hashes, SHA256 *removed_hashes, int *num_removed);
|
||||
int file_tree_write(FileTree *ft, string path, uint64_t off, uint64_t len, uint32_t num_chunks, SHA256 *prev_hashes, SHA256 *hashes, SHA256 *removed_hashes, int *num_removed);
|
||||
int file_tree_read(FileTree *ft, string path, uint64_t off, uint64_t len, uint64_t *chunk_size, SHA256 *hashes, int max_hashes);
|
||||
string file_tree_strerror(int code);
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <arpa/inet.h> // inet_ntop
|
||||
#endif
|
||||
|
||||
#include "message.h"
|
||||
|
||||
|
||||
@@ -628,7 +628,7 @@ process_client_write(MetadataServer *state, int conn_idx, ByteView msg)
|
||||
}
|
||||
|
||||
int ret = file_tree_write(&state->file_tree, path, offset, length,
|
||||
old_hashes, new_hashes, removed_hashes, &num_removed);
|
||||
num_chunks, old_hashes, new_hashes, removed_hashes, &num_removed);
|
||||
|
||||
if (ret < 0) {
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <direct.h> // _mkdir
|
||||
#include <bcrypt.h>
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
Reference in New Issue
Block a user