From dcee6222be8ba4e1ba4c22f6b56339bc50f624e1 Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Wed, 19 Oct 2022 11:24:24 +0200 Subject: [PATCH] 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 --- btrbk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/btrbk b/btrbk index abc85d9..f34dca7 100755 --- a/btrbk +++ b/btrbk @@ -1857,7 +1857,7 @@ sub btrfs_send_to_file($$$;$$) ); if(defined($ret)) { 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 { push @cmd_err, "failed to check target file (not present or zero length): $check_file"; }