refactor: merge File/FileReceive, add optional metadata transfer with -M flag
- Remove FileReceive struct; use File everywhere with nullable FileMetadata* - Remove struct stat from File; file size lives in Data->size (data_create_reserve) - Add FileMetadata struct (mode, uid, gid, mtime) sent conditionally over wire - Add -M / --preserve flag to client - Restore permissions, ownership, timestamps on disk write - Wire format uses per-file present flag for metadata (zero overhead when off)
This commit is contained in:
@@ -13,6 +13,17 @@ Data *data_create_empty(size_t data_size) {
|
||||
return data_create(data, data_size);
|
||||
}
|
||||
|
||||
Data *data_create_reserve(size_t size) {
|
||||
Data *d = malloc(sizeof(Data));
|
||||
if (d == NULL) {
|
||||
log_message(LOG_LEVEL_ERROR, "Could not allocate memory for data");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
d->data = NULL;
|
||||
d->size = size;
|
||||
return d;
|
||||
}
|
||||
|
||||
Data *data_create(void *data, size_t data_size) {
|
||||
Data *new_data = malloc(sizeof(Data));
|
||||
if (new_data == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user