refactor: const-correct delete-manifest API; apply clang-format
This commit is contained in:
@@ -1653,7 +1653,7 @@ static bool send_files_run(Config* config, SendFilesState* state) {
|
|||||||
/* Completion tail: send the late delete manifest and captured directory times,
|
/* Completion tail: send the late delete manifest and captured directory times,
|
||||||
* finalize the receiver handshake, remove transferred sources and report stats.
|
* finalize the receiver handshake, remove transferred sources and report stats.
|
||||||
* Returns the rsync-compatible exit code. */
|
* Returns the rsync-compatible exit code. */
|
||||||
static int send_files_finalize(Config* config, SendFilesState* state) {
|
static int send_files_finalize(const Config* config, SendFilesState* state) {
|
||||||
Client* client = state->client;
|
Client* client = state->client;
|
||||||
if (directory_scanner_failed(state->scanner))
|
if (directory_scanner_failed(state->scanner))
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1916,8 +1916,8 @@ int send_files_multithreaded(Config* config) {
|
|||||||
now_mono.tv_nsec = 0;
|
now_mono.tv_nsec = 0;
|
||||||
}
|
}
|
||||||
context->stop_condition =
|
context->stop_condition =
|
||||||
stop_condition_make(config->stop_after_mins > 0, config->stop_after_mins, config->cli.stop_at_set,
|
stop_condition_make(config->stop_after_mins > 0, config->stop_after_mins,
|
||||||
config->stop_at, now_mono);
|
config->cli.stop_at_set, config->stop_at, now_mono);
|
||||||
bool collect_excluded = config->use_delete && !config->delete_excluded;
|
bool collect_excluded = config->use_delete && !config->delete_excluded;
|
||||||
unsigned long long pre_scan_non_dir = 0;
|
unsigned long long pre_scan_non_dir = 0;
|
||||||
if (config->use_delete) {
|
if (config->use_delete) {
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ static ReceiverStep receiver_handle_mkdir(ReceiverPendingState* state) {
|
|||||||
return RECEIVER_STEP_NEXT;
|
return RECEIVER_STEP_NEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ReceiverStep receiver_handle_dir_times(ReceiverPendingState* state) {
|
static ReceiverStep receiver_handle_dir_times(const ReceiverPendingState* state) {
|
||||||
if (!receiver_process_dir_times(state->fd, state->config, state->sink))
|
if (!receiver_process_dir_times(state->fd, state->config, state->sink))
|
||||||
return RECEIVER_STEP_ERROR;
|
return RECEIVER_STEP_ERROR;
|
||||||
return RECEIVER_STEP_NEXT;
|
return RECEIVER_STEP_NEXT;
|
||||||
|
|||||||
+2
-1
@@ -341,7 +341,8 @@ bool config_derived_use_metadata(const Config* config) {
|
|||||||
config->chown_uid_set || config->chown_gid_set || config->usermap_count > 0 ||
|
config->chown_uid_set || config->chown_gid_set || config->usermap_count > 0 ||
|
||||||
config->groupmap_count > 0 || config->update)
|
config->groupmap_count > 0 || config->update)
|
||||||
return true;
|
return true;
|
||||||
return (config->use_incremental || config->use_delta) && !config->cli.metadata_explicitly_disabled;
|
return (config->use_incremental || config->use_delta) &&
|
||||||
|
!config->cli.metadata_explicitly_disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool config_has_basis(const Config* config) {
|
bool config_has_basis(const Config* config) {
|
||||||
|
|||||||
+17
-17
@@ -136,7 +136,7 @@ typedef struct {
|
|||||||
alternate basis directories are never destination content and are skipped at
|
alternate basis directories are never destination content and are skipped at
|
||||||
any depth. Returns true unless a traversal/unlink error aborted the walk;
|
any depth. Returns true unless a traversal/unlink error aborted the walk;
|
||||||
the budget's limit_hit/skipped fields report a cap-stopped run. */
|
the budget's limit_hit/skipped fields report a cap-stopped run. */
|
||||||
static bool delete_extras_budgeted_observed(const Config* config, DeleteManifest* manifest,
|
static bool delete_extras_budgeted_observed(const Config* config, const DeleteManifest* manifest,
|
||||||
DeleteBudgetState* budget, DeletePathObserver observer,
|
DeleteBudgetState* budget, DeletePathObserver observer,
|
||||||
void* observer_context) {
|
void* observer_context) {
|
||||||
if (!config || !manifest || !manifest->keeps)
|
if (!config || !manifest || !manifest->keeps)
|
||||||
@@ -177,7 +177,7 @@ static bool delete_extras_budgeted_observed(const Config* config, DeleteManifest
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool delete_extras_budgeted(const Config* config, DeleteManifest* manifest,
|
static bool delete_extras_budgeted(const Config* config, const DeleteManifest* manifest,
|
||||||
DeleteBudgetState* budget) {
|
DeleteBudgetState* budget) {
|
||||||
return delete_extras_budgeted_observed(config, manifest, budget, NULL, NULL);
|
return delete_extras_budgeted_observed(config, manifest, budget, NULL, NULL);
|
||||||
}
|
}
|
||||||
@@ -215,7 +215,8 @@ static void prefixed_delete_observer(void* context, const char* rel) {
|
|||||||
--max-delete budget: once it is exhausted the remaining requests are skipped
|
--max-delete budget: once it is exhausted the remaining requests are skipped
|
||||||
and counted. Returns false only on a genuine error (a confinement failure on
|
and counted. Returns false only on a genuine error (a confinement failure on
|
||||||
a validated path or an I/O error), which fails the run. */
|
a validated path or an I/O error), which fails the run. */
|
||||||
static bool delete_missing_args_budgeted_observed(const Config* config, DeleteManifest* manifest,
|
static bool delete_missing_args_budgeted_observed(const Config* config,
|
||||||
|
const DeleteManifest* manifest,
|
||||||
DeleteBudgetState* budget,
|
DeleteBudgetState* budget,
|
||||||
DeletePathObserver observer,
|
DeletePathObserver observer,
|
||||||
void* observer_context) {
|
void* observer_context) {
|
||||||
@@ -376,8 +377,8 @@ static bool delete_missing_args_budgeted_observed(const Config* config, DeleteMa
|
|||||||
|
|
||||||
/* Public wrappers used outside the commit path (and by unit tests): no
|
/* Public wrappers used outside the commit path (and by unit tests): no
|
||||||
--max-delete budget. */
|
--max-delete budget. */
|
||||||
bool manifest_would_delete_list(const Config* config, DeleteManifest* manifest, ArrayList* out,
|
bool manifest_would_delete_list(const Config* config, const DeleteManifest* manifest,
|
||||||
size_t* count_out) {
|
ArrayList* out, size_t* count_out) {
|
||||||
if (count_out)
|
if (count_out)
|
||||||
*count_out = 0;
|
*count_out = 0;
|
||||||
if (!config || !manifest || !manifest->keeps || !out)
|
if (!config || !manifest || !manifest->keeps || !out)
|
||||||
@@ -391,30 +392,28 @@ bool manifest_would_delete_list(const Config* config, DeleteManifest* manifest,
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool manifest_delete_extras(const Config* config, DeleteManifest* manifest) {
|
bool manifest_delete_extras(const Config* config, const DeleteManifest* manifest) {
|
||||||
DeleteBudgetState budget = {
|
DeleteBudgetState budget = {
|
||||||
.max_delete = SIZE_MAX, .deleted = 0, .skipped = 0, .limit_hit = false};
|
.max_delete = SIZE_MAX, .deleted = 0, .skipped = 0, .limit_hit = false};
|
||||||
return delete_extras_budgeted(config, manifest, &budget);
|
return delete_extras_budgeted(config, manifest, &budget);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool manifest_delete_missing_args(const Config* config, DeleteManifest* manifest) {
|
bool manifest_delete_missing_args(const Config* config, const DeleteManifest* manifest) {
|
||||||
DeleteBudgetState budget = {
|
DeleteBudgetState budget = {
|
||||||
.max_delete = SIZE_MAX, .deleted = 0, .skipped = 0, .limit_hit = false};
|
.max_delete = SIZE_MAX, .deleted = 0, .skipped = 0, .limit_hit = false};
|
||||||
return delete_missing_args_budgeted_observed(config, manifest, &budget, NULL, NULL);
|
return delete_missing_args_budgeted_observed(config, manifest, &budget, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool manifest_delete_missing_args_limited(const Config* config, DeleteManifest* manifest,
|
bool manifest_delete_missing_args_limited(const Config* config, const DeleteManifest* manifest,
|
||||||
size_t max_delete, size_t* deleted, size_t* skipped,
|
size_t max_delete, size_t* deleted, size_t* skipped,
|
||||||
bool* limit_hit) {
|
bool* limit_hit) {
|
||||||
return manifest_delete_missing_args_limited_observed(config, manifest, max_delete, deleted,
|
return manifest_delete_missing_args_limited_observed(config, manifest, max_delete, deleted,
|
||||||
skipped, limit_hit, NULL, NULL);
|
skipped, limit_hit, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool manifest_delete_missing_args_limited_observed(const Config* config, DeleteManifest* manifest,
|
bool manifest_delete_missing_args_limited_observed(
|
||||||
size_t max_delete, size_t* deleted,
|
const Config* config, const DeleteManifest* manifest, size_t max_delete, size_t* deleted,
|
||||||
size_t* skipped, bool* limit_hit,
|
size_t* skipped, bool* limit_hit, DeletePathObserver observer, void* observer_context) {
|
||||||
DeletePathObserver observer,
|
|
||||||
void* observer_context) {
|
|
||||||
DeleteBudgetState budget = {
|
DeleteBudgetState budget = {
|
||||||
.max_delete = max_delete, .deleted = 0, .skipped = 0, .limit_hit = false};
|
.max_delete = max_delete, .deleted = 0, .skipped = 0, .limit_hit = false};
|
||||||
bool ok =
|
bool ok =
|
||||||
@@ -435,17 +434,18 @@ bool manifest_delete_missing_args_limited_observed(const Config* config, DeleteM
|
|||||||
removal fail). The ordinary extras walk then runs when --delete is active.
|
removal fail). The ordinary extras walk then runs when --delete is active.
|
||||||
Both draw from one --max-delete budget; the result reports a cap-stopped
|
Both draw from one --max-delete budget; the result reports a cap-stopped
|
||||||
(partial) commit distinctly so the client can exit 25 like rsync. */
|
(partial) commit distinctly so the client can exit 25 like rsync. */
|
||||||
DeleteCommitResult manifest_delete_all(const Config* config, DeleteManifest* manifest) {
|
DeleteCommitResult manifest_delete_all(const Config* config, const DeleteManifest* manifest) {
|
||||||
return manifest_delete_all_counted(config, manifest, NULL);
|
return manifest_delete_all_counted(config, manifest, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteCommitResult manifest_delete_all_counted(const Config* config, DeleteManifest* manifest,
|
DeleteCommitResult manifest_delete_all_counted(const Config* config, const DeleteManifest* manifest,
|
||||||
size_t* deleted) {
|
size_t* deleted) {
|
||||||
return manifest_delete_all_observed(config, manifest, deleted, NULL, NULL);
|
return manifest_delete_all_observed(config, manifest, deleted, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteCommitResult manifest_delete_all_observed(const Config* config, DeleteManifest* manifest,
|
DeleteCommitResult manifest_delete_all_observed(const Config* config,
|
||||||
size_t* deleted, DeletePathObserver observer,
|
const DeleteManifest* manifest, size_t* deleted,
|
||||||
|
DeletePathObserver observer,
|
||||||
void* observer_context) {
|
void* observer_context) {
|
||||||
if (deleted)
|
if (deleted)
|
||||||
*deleted = 0;
|
*deleted = 0;
|
||||||
|
|||||||
+13
-14
@@ -44,7 +44,7 @@ DeleteManifest* receive_manifest_entries(int fd);
|
|||||||
protected-prefix skips). `--max-delete` and `--force` are honored here. The
|
protected-prefix skips). `--max-delete` and `--force` are honored here. The
|
||||||
caller decides WHEN to run it based on the negotiated delete timing. Returns
|
caller decides WHEN to run it based on the negotiated delete timing. Returns
|
||||||
false (and the transfer fails) when the deletion cannot be committed. */
|
false (and the transfer fails) when the deletion cannot be committed. */
|
||||||
bool manifest_delete_extras(const Config* config, DeleteManifest* manifest);
|
bool manifest_delete_extras(const Config* config, const DeleteManifest* manifest);
|
||||||
/* --delete-missing-args exact-path deletions: remove each destination mirror
|
/* --delete-missing-args exact-path deletions: remove each destination mirror
|
||||||
in `manifest->missing` (never blocked by the protected prefixes, staging dir
|
in `manifest->missing` (never blocked by the protected prefixes, staging dir
|
||||||
and basis dirs excluded). A regular file/symlink is unlinked; an empty
|
and basis dirs excluded). A regular file/symlink is unlinked; an empty
|
||||||
@@ -53,22 +53,20 @@ bool manifest_delete_extras(const Config* config, DeleteManifest* manifest);
|
|||||||
parity). A missing path is a no-op. Returns false only on a genuine
|
parity). A missing path is a no-op. Returns false only on a genuine
|
||||||
confinement or I/O error (the run then fails); tolerated per-path cases are
|
confinement or I/O error (the run then fails); tolerated per-path cases are
|
||||||
reported and skipped. */
|
reported and skipped. */
|
||||||
bool manifest_delete_missing_args(const Config* config, DeleteManifest* manifest);
|
bool manifest_delete_missing_args(const Config* config, const DeleteManifest* manifest);
|
||||||
/* Budgeted form of manifest_delete_missing_args for the per-directory delete
|
/* Budgeted form of manifest_delete_missing_args for the per-directory delete
|
||||||
session: each removed mirror draws from `max_delete` (SIZE_MAX = unlimited)
|
session: each removed mirror draws from `max_delete` (SIZE_MAX = unlimited)
|
||||||
and the tallies are accumulated into `*deleted`/`*skipped`. `*limit_hit` is set
|
and the tallies are accumulated into `*deleted`/`*skipped`. `*limit_hit` is set
|
||||||
when the budget stopped the pass with entries left over. Returns false only
|
when the budget stopped the pass with entries left over. Returns false only
|
||||||
on a genuine deletion error. */
|
on a genuine deletion error. */
|
||||||
bool manifest_delete_missing_args_limited(const Config* config, DeleteManifest* manifest,
|
bool manifest_delete_missing_args_limited(const Config* config, const DeleteManifest* manifest,
|
||||||
size_t max_delete, size_t* deleted, size_t* skipped,
|
size_t max_delete, size_t* deleted, size_t* skipped,
|
||||||
bool* limit_hit);
|
bool* limit_hit);
|
||||||
/* Observer-aware form of manifest_delete_missing_args_limited: `observer` (may
|
/* Observer-aware form of manifest_delete_missing_args_limited: `observer` (may
|
||||||
be NULL) is invoked for every destination-relative path truly removed. */
|
be NULL) is invoked for every destination-relative path truly removed. */
|
||||||
bool manifest_delete_missing_args_limited_observed(const Config* config, DeleteManifest* manifest,
|
bool manifest_delete_missing_args_limited_observed(
|
||||||
size_t max_delete, size_t* deleted,
|
const Config* config, const DeleteManifest* manifest, size_t max_delete, size_t* deleted,
|
||||||
size_t* skipped, bool* limit_hit,
|
size_t* skipped, bool* limit_hit, DeletePathObserver observer, void* observer_context);
|
||||||
DeletePathObserver observer,
|
|
||||||
void* observer_context);
|
|
||||||
/* Outcome of committing a delete manifest. LIMIT_REACHED reports rsync's
|
/* Outcome of committing a delete manifest. LIMIT_REACHED reports rsync's
|
||||||
partial --max-delete result: the budget allowed some deletions and the rest
|
partial --max-delete result: the budget allowed some deletions and the rest
|
||||||
were skipped (the run still stores all file data but the client exits 25). */
|
were skipped (the run still stores all file data but the client exits 25). */
|
||||||
@@ -84,15 +82,16 @@ typedef enum {
|
|||||||
share one --max-delete budget. Returns DELETE_COMMIT_OK when nothing was to
|
share one --max-delete budget. Returns DELETE_COMMIT_OK when nothing was to
|
||||||
do or everything committed, DELETE_COMMIT_LIMIT_REACHED when the budget
|
do or everything committed, DELETE_COMMIT_LIMIT_REACHED when the budget
|
||||||
stopped part of the work, or DELETE_COMMIT_ERROR on a genuine failure. */
|
stopped part of the work, or DELETE_COMMIT_ERROR on a genuine failure. */
|
||||||
DeleteCommitResult manifest_delete_all(const Config* config, DeleteManifest* manifest);
|
DeleteCommitResult manifest_delete_all(const Config* config, const DeleteManifest* manifest);
|
||||||
/* Like manifest_delete_all, but reports how many destination entries the commit
|
/* Like manifest_delete_all, but reports how many destination entries the commit
|
||||||
removed (for the end-of-transfer wire stats). `deleted` may be NULL. */
|
removed (for the end-of-transfer wire stats). `deleted` may be NULL. */
|
||||||
DeleteCommitResult manifest_delete_all_counted(const Config* config, DeleteManifest* manifest,
|
DeleteCommitResult manifest_delete_all_counted(const Config* config, const DeleteManifest* manifest,
|
||||||
size_t* deleted);
|
size_t* deleted);
|
||||||
/* Observer-aware form of manifest_delete_all_counted: `observer` (may be NULL)
|
/* Observer-aware form of manifest_delete_all_counted: `observer` (may be NULL)
|
||||||
is invoked for every destination-relative path truly removed. */
|
is invoked for every destination-relative path truly removed. */
|
||||||
DeleteCommitResult manifest_delete_all_observed(const Config* config, DeleteManifest* manifest,
|
DeleteCommitResult manifest_delete_all_observed(const Config* config,
|
||||||
size_t* deleted, DeletePathObserver observer,
|
const DeleteManifest* manifest, size_t* deleted,
|
||||||
|
DeletePathObserver observer,
|
||||||
void* observer_context);
|
void* observer_context);
|
||||||
|
|
||||||
/* -n/--dry-run --delete would-delete reporting: walk the destination exactly as
|
/* -n/--dry-run --delete would-delete reporting: walk the destination exactly as
|
||||||
@@ -100,7 +99,7 @@ DeleteCommitResult manifest_delete_all_observed(const Config* config, DeleteMani
|
|||||||
WOULD be removed to `out`, without touching disk. Uses the same staging-dir,
|
WOULD be removed to `out`, without touching disk. Uses the same staging-dir,
|
||||||
basis-dir and protected-prefix skips as the real commit. Returns true on a
|
basis-dir and protected-prefix skips as the real commit. Returns true on a
|
||||||
clean walk; `*count_out` receives the number of paths appended. */
|
clean walk; `*count_out` receives the number of paths appended. */
|
||||||
bool manifest_would_delete_list(const Config* config, DeleteManifest* manifest, ArrayList* out,
|
bool manifest_would_delete_list(const Config* config, const DeleteManifest* manifest,
|
||||||
size_t* count_out);
|
ArrayList* out, size_t* count_out);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user