diff --git a/btrbk b/btrbk index 38ca470..75a7b95 100755 --- a/btrbk +++ b/btrbk @@ -2075,28 +2075,24 @@ sub system_read_raw_info_dir($) } -sub system_write_raw_info($$) +sub system_write_raw_info($$;@) { my $vol = shift // die; my $raw_info = shift // die; - + my %opts = @_; + my $append = $opts{append}; my $info_file = $vol->{PATH} . '.info'; - my @line; - push @line, "#btrbk-v$VERSION"; - push @line, "# Do not edit this file"; # sort by %raw_info_sort, then by key - foreach(sort { (($raw_info_sort{$a} || 99) <=> ($raw_info_sort{$b} || 99)) || ($a cmp $b) } keys %$raw_info) { + my @line = $append ? () : ("#btrbk-v$VERSION", "# Do not edit this file"); + foreach(sort { (($raw_info_sort{$a} // 99) <=> ($raw_info_sort{$b} // 99)) || ($a cmp $b) } keys %$raw_info) { push @line, ($_ . '=' . $raw_info->{$_}); } - DEBUG "Creating raw info file " . ($raw_info->{INCOMPLETE} ? "(incomplete)" : "(complete)") . ": $info_file"; - my $echo_text = (join '\n', @line); - TRACE "DUMP INFO_FILE=$info_file\n" . join("\n", @line) if($do_trace); - + DEBUG "Writing (" . ($append ? "append:" . join(",", keys %$raw_info) : "create") . ") raw info file: $info_file"; my $ret = run_cmd( { cmd => [ 'echo', '-e', '-n', '"' . (join '\n', @line) . '\n"' ] }, - { redirect_to_file => { unsafe => $info_file }, + { ($append ? "append_to_file" : "redirect_to_file") => { unsafe => $info_file }, rsh => vinfo_rsh($vol), }); return undef unless(defined($ret));