btrbk: append to info file instead of rewriting

A redirection (e.g. `echo foo > bar.info`) can cause empty (zero-size)
files in some circumstances.

We still write INCOMPLETE=1 to the info file before send/receive, but
instead of re-creating it without the INCOMPLETE flag, we append
INCOMPLETE=0 (keeping up compatibility with old versions of btrbk).

Ref: 4e5ae975d8 btrbk: ignore zero-size info files
ionice
Axel Burri 2022-10-19 11:24:24 +02:00
parent 51b2a5a9f5
commit dcee6222be
1 changed files with 1 additions and 1 deletions

2
btrbk
View File

@ -1857,7 +1857,7 @@ sub btrfs_send_to_file($$$;$$)
); );
if(defined($ret)) { if(defined($ret)) {
delete $raw_info{INCOMPLETE}; delete $raw_info{INCOMPLETE};
$ret = system_write_raw_info($vol_received, \%raw_info); $ret = system_write_raw_info($vol_received, { INCOMPLETE => 0 }, append => 1);
} else { } else {
push @cmd_err, "failed to check target file (not present or zero length): $check_file"; push @cmd_err, "failed to check target file (not present or zero length): $check_file";
} }