@@ -132,6 +132,9 @@ pub enum ArchiveCommands {
132132 /// S3 endpoint URL.
133133 #[ arg( long, default_value = FOREST_ARCHIVE_S3_ENDPOINT ) ]
134134 endpoint : String ,
135+ /// Don't generate or upload files, just show what would be done.
136+ #[ arg( long, default_value_t = false ) ]
137+ dry_run : bool ,
135138 } ,
136139}
137140
@@ -189,7 +192,8 @@ impl ArchiveCommands {
189192 Self :: SyncBucket {
190193 snapshot_files,
191194 endpoint,
192- } => sync_bucket ( snapshot_files, endpoint) . await ,
195+ dry_run,
196+ } => sync_bucket ( snapshot_files, endpoint, dry_run) . await ,
193197 }
194198 }
195199}
@@ -812,7 +816,11 @@ async fn export_diff_snapshot(
812816// what is missing. If the input set of snapshot files can be used to generate
813817// missing lite or diff snapshots, they'll be generated and uploaded to the S3
814818// bucket.
815- async fn sync_bucket ( snapshot_files : Vec < PathBuf > , endpoint : String ) -> anyhow:: Result < ( ) > {
819+ async fn sync_bucket (
820+ snapshot_files : Vec < PathBuf > ,
821+ endpoint : String ,
822+ dry_run : bool ,
823+ ) -> anyhow:: Result < ( ) > {
816824 check_aws_config ( & endpoint) ?;
817825
818826 let store = Arc :: new ( ManyCar :: try_from ( snapshot_files) ?) ;
@@ -854,7 +862,11 @@ async fn sync_bucket(snapshot_files: Vec<PathBuf>, endpoint: String) -> anyhow::
854862 epoch,
855863 )
856864 . await ?;
857- upload_to_forest_bucket ( output_path, & info. network , "lite" ) ?;
865+ if !dry_run {
866+ upload_to_forest_bucket ( output_path, & info. network , "lite" ) ?;
867+ } else {
868+ println ! ( " {}: Would upload lite snapshot to S3" , epoch) ;
869+ }
858870 }
859871 }
860872
@@ -869,7 +881,11 @@ async fn sync_bucket(snapshot_files: Vec<PathBuf>, endpoint: String) -> anyhow::
869881 epoch,
870882 )
871883 . await ?;
872- upload_to_forest_bucket ( output_path, & info. network , "diff" ) ?;
884+ if !dry_run {
885+ upload_to_forest_bucket ( output_path, & info. network , "diff" ) ?;
886+ } else {
887+ println ! ( " {}: Would upload diff snapshot to S3" , epoch) ;
888+ }
873889 }
874890 }
875891 Ok ( ( ) )
0 commit comments