In src/shared/file.c, the receive_delta_file() function (lines 263-303) contains duplicated code for receiving a file when delta transfer falls back (STATUS_NEXT after STATUS_DELTA_SIGNATURE). The decompression and metadata handling logic is essentially identical to file_receive() (lines 470-503).
Specifically, lines 267-303 duplicate the pattern of:
Creating a File from the path
Receiving metadata if use_metadata is set
Receiving file data
Decompressing if needed
Setting the data on the file
Location
src/shared/file.c:263-303 and src/shared/file.c:470-503
Suggested Fix
Refactor receive_delta_file() to call file_receive() instead of duplicating the logic. The delta fallback path can use file_receive() and then return the received file directly.
if(resp==STATUS_NEXT){delta_signature_destroy(sig);free(old_data);returnfile_receive(config,fd);// reuse existing function
}
Severity
Medium
Category
Quality
## Description
In `src/shared/file.c`, the `receive_delta_file()` function (lines 263-303) contains duplicated code for receiving a file when delta transfer falls back (`STATUS_NEXT` after `STATUS_DELTA_SIGNATURE`). The decompression and metadata handling logic is essentially identical to `file_receive()` (lines 470-503).
Specifically, lines 267-303 duplicate the pattern of:
1. Creating a `File` from the path
2. Receiving metadata if `use_metadata` is set
3. Receiving file data
4. Decompressing if needed
5. Setting the data on the file
## Location
`src/shared/file.c:263-303` and `src/shared/file.c:470-503`
## Suggested Fix
Refactor `receive_delta_file()` to call `file_receive()` instead of duplicating the logic. The delta fallback path can use `file_receive()` and then return the received file directly.
```c
if (resp == STATUS_NEXT) {
delta_signature_destroy(sig);
free(old_data);
return file_receive(config, fd); // reuse existing function
}
```
## Severity
Medium
## Category
Quality
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Description
In
src/shared/file.c, thereceive_delta_file()function (lines 263-303) contains duplicated code for receiving a file when delta transfer falls back (STATUS_NEXTafterSTATUS_DELTA_SIGNATURE). The decompression and metadata handling logic is essentially identical tofile_receive()(lines 470-503).Specifically, lines 267-303 duplicate the pattern of:
Filefrom the pathuse_metadatais setLocation
src/shared/file.c:263-303andsrc/shared/file.c:470-503Suggested Fix
Refactor
receive_delta_file()to callfile_receive()instead of duplicating the logic. The delta fallback path can usefile_receive()and then return the received file directly.Severity
Medium
Category
Quality