@@ -142,15 +142,20 @@ pub async fn resolve_parseable_metadata() -> Result<(), ObjectStorageError> {
142142 Some ( "Could not start the server because metadata not found in storage" )
143143 }
144144 EnvChange :: NewStaging => {
145- put_staging_metadata ( remote_metadata. as_ref ( ) . expect ( "remote metadata exists" ) ) ?;
145+ let mut remote_meta = remote_metadata. expect ( "remote metadata exists" ) ;
146+ create_dir_all ( CONFIG . staging_dir ( ) ) ?;
147+ remote_meta. staging = CONFIG . staging_dir ( ) . canonicalize ( ) ?;
148+ create_remote_metadata ( & remote_meta) . await ?;
149+ put_staging_metadata ( & remote_meta) ?;
146150
147- // allow new staging directories
148- return Ok ( ( ) ) ;
151+ None
149152 }
150153 EnvChange :: CreateBoth => {
151154 let metadata = StorageMetadata :: new ( ) ;
152155 create_remote_metadata ( & metadata) . await ?;
153- create_staging_metadata ( & metadata) ?;
156+ create_dir_all ( CONFIG . staging_dir ( ) ) ?;
157+ put_staging_metadata ( & metadata) ?;
158+
154159 None
155160 }
156161 } ;
@@ -173,11 +178,6 @@ async fn create_remote_metadata(metadata: &StorageMetadata) -> Result<(), Object
173178 client. put_metadata ( metadata) . await
174179}
175180
176- fn create_staging_metadata ( metadata : & StorageMetadata ) -> std:: io:: Result < ( ) > {
177- create_dir_all ( CONFIG . staging_dir ( ) ) ?;
178- put_staging_metadata ( metadata)
179- }
180-
181181lazy_static ! {
182182 pub static ref CACHED_FILES : Mutex <FileTable <FileLink >> = Mutex :: new( FileTable :: new( ) ) ;
183183 pub static ref STORAGE_RUNTIME : Arc <RuntimeEnv > = CONFIG . storage( ) . get_datafusion_runtime( ) ;
0 commit comments