@@ -7,7 +7,7 @@ use std::{
7
7
8
8
use serde:: { Deserialize , Serialize } ;
9
9
use thiserror:: Error ;
10
- use tracing:: { debug, error, field:: display as as_display} ;
10
+ use tracing:: { debug, error, field:: display as as_display, info } ;
11
11
12
12
/// Bundles should have the following structure on the filesystem:
13
13
///
@@ -117,12 +117,6 @@ pub struct BundleMeta {
117
117
versions_directory : PathBuf ,
118
118
}
119
119
120
- // pub enum BinaryAvailability {
121
- // NotFound,
122
- // PermissionDenied,
123
- // Ok,
124
- // }
125
-
126
120
impl Bundle {
127
121
/// Constructs a new [`Bundle`] based on a path.
128
122
/// Will read `bundle/meta.json` and error if invalid.
@@ -149,13 +143,17 @@ impl Bundle {
149
143
pub fn path_to ( & self , version : impl Into < OsString > ) -> UnvalidatedVersionPath {
150
144
let version = version. into ( ) ;
151
145
UnvalidatedVersionPath :: new (
152
- self . path
153
- . join ( & self . meta . versions_directory )
146
+ self . versions_path ( )
154
147
. join ( version)
155
148
. join ( & self . meta . binary_name ) ,
156
149
)
157
150
}
158
151
152
+ /// Provides the full path the the versions directory
153
+ pub fn versions_path ( & self ) -> PathBuf {
154
+ self . path . join ( & self . meta . versions_directory )
155
+ }
156
+
159
157
/// Returns a [`PathBuf`] to the Bundle's genesis.json
160
158
pub fn genesis_json ( & self ) -> PathBuf {
161
159
self . path . join ( "genesis.json" )
@@ -168,6 +166,19 @@ impl Bundle {
168
166
}
169
167
}
170
168
169
+ pub fn log_bundle ( bundle : & Bundle ) {
170
+ let versions = fs:: read_dir ( bundle. versions_path ( ) )
171
+ . expect ( "can't read contents of versions path" )
172
+ . map ( |v| {
173
+ v. expect ( "can't read version in dir" )
174
+ . path ( )
175
+ . into_os_string ( )
176
+ } )
177
+ . collect :: < Vec < _ > > ( ) ;
178
+
179
+ info ! ( target: "unionvisor" , ?bundle, genesis=?bundle. genesis_json( ) . into_os_string( ) , ?versions, "running with bundle" ) ;
180
+ }
181
+
171
182
#[ derive( Debug , Error ) ]
172
183
pub enum NewBundleError {
173
184
#[ error( "cannot read bundle/meta.json" ) ]
0 commit comments