File tree Expand file tree Collapse file tree 4 files changed +17
-15
lines changed
Expand file tree Collapse file tree 4 files changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ pub fn display_diff(
7070 size_old,
7171 size_new,
7272 } ) ?;
73- print ! ( "{json}" ) ;
73+ println ! ( "{json}" ) ;
7474 Ok ( ( ) )
7575}
7676
Original file line number Diff line number Diff line change @@ -59,8 +59,7 @@ struct Cli {
5959 #[ arg( long, default_value_t = false , global = true ) ]
6060 force_correctness : bool ,
6161
62- /// Does not display the normal, human readable diff, but rather
63- /// serialized to json
62+ /// Outputs the diff in JSON format instead of the normal, human-readable diff.
6463 ///
6564 /// Requires the "json" feature.
6665 #[ arg( long, default_value_t = false , global = true ) ]
Original file line number Diff line number Diff line change @@ -8,10 +8,6 @@ mod db_lazy;
88mod nix_command;
99mod queries;
1010
11- pub mod store {
12- pub use crate :: store:: db_lazy:: LazyDBConnection ;
13- }
14-
1511use std:: {
1612 fmt:: Display ,
1713 iter:: Iterator ,
@@ -25,13 +21,11 @@ use anyhow::{
2521use log:: warn;
2622use size:: Size ;
2723
28- use crate :: {
29- StorePath ,
30- store:: {
31- db_eager:: EagerDBConnection ,
32- nix_command:: CommandBackend ,
33- store:: LazyDBConnection ,
34- } ,
24+ use crate :: StorePath ;
25+ pub use crate :: store:: {
26+ db_eager:: EagerDBConnection ,
27+ db_lazy:: LazyDBConnection ,
28+ nix_command:: CommandBackend ,
3529} ;
3630/// The normal database connection
3731pub const DATABASE_PATH : & str = "file:/nix/var/nix/db/db.sqlite" ;
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ fn nix_command_query<'a>(
5757}
5858
5959impl < ' a > StoreBackend < ' a > for CommandBackend {
60- /// Does nothing (we spawn a new process everytime ).
60+ /// Does nothing (we spawn a new process every time ).
6161 fn connect ( & mut self ) -> Result < ( ) > {
6262 Ok ( ( ) )
6363 }
@@ -80,6 +80,15 @@ impl<'a> StoreBackend<'a> for CommandBackend {
8080 . arg ( path. join ( "sw" ) )
8181 . output ( )
8282 . context ( anyhow ! ( "Encountered error while executing nix command" ) ) ?;
83+
84+ if !cmd_res. status . success ( ) {
85+ let stderr = String :: from_utf8_lossy ( & cmd_res. stderr ) ;
86+ return Err ( anyhow ! (
87+ "nix command exited with non-zero status {}: {}" ,
88+ cmd_res. status,
89+ stderr. trim( )
90+ ) ) ;
91+ }
8392 let text = str:: from_utf8 ( & cmd_res. stdout ) ?;
8493 if let Some ( bytes_text) = text. split_whitespace ( ) . last ( )
8594 && let Ok ( bytes) = bytes_text. parse :: < u64 > ( )
You can’t perform that action at this time.
0 commit comments