@@ -18,6 +18,7 @@ use rsa::{
1818 RsaPrivateKey ,
1919} ;
2020use thiserror:: Error ;
21+ use tracing:: instrument;
2122
2223use crate :: {
2324 github:: { GitHubError , GitHubRfdRepo } ,
@@ -260,12 +261,15 @@ impl PdfStorageCtx {
260261
261262#[ async_trait]
262263impl PdfStorage for PdfStorageCtx {
264+ #[ instrument( skip( self , pdf) , fields( locations = ?self . locations) ) ]
263265 async fn store_rfd_pdf (
264266 & self ,
265267 external_id : Option < & str > ,
266268 filename : & str ,
267269 pdf : & RfdPdf ,
268270 ) -> Vec < Result < PdfFileLocation , RfdPdfError > > {
271+ tracing:: info!( "Attempt to store PFD" ) ;
272+
269273 if let Some ( location) = self . locations . get ( 0 ) {
270274 let req = File {
271275 copy_requires_writer_permission : Some ( true ) ,
@@ -279,20 +283,24 @@ impl PdfStorage for PdfStorageCtx {
279283 let stream = Cursor :: new ( pdf. contents . clone ( ) ) ;
280284
281285 let response = match external_id {
282- Some ( file_id) => self
283- . client
284- . files ( )
285- . update ( req, file_id)
286- . upload_resumable ( stream, "application_pdf" . parse ( ) . unwrap ( ) )
287- . await
288- . map_err ( RfdPdfError :: Remote ) ,
289- None => self
290- . client
291- . files ( )
292- . create ( req)
293- . upload_resumable ( stream, "application_pdf" . parse ( ) . unwrap ( ) )
294- . await
295- . map_err ( RfdPdfError :: Remote ) ,
286+ Some ( file_id) => {
287+ tracing:: info!( ?file_id, "Updating existing PDF with new version" ) ;
288+ self . client
289+ . files ( )
290+ . update ( req, file_id)
291+ . upload_resumable ( stream, "application_pdf" . parse ( ) . unwrap ( ) )
292+ . await
293+ . map_err ( RfdPdfError :: Remote )
294+ }
295+ None => {
296+ tracing:: info!( "Creating new PDF file" ) ;
297+ self . client
298+ . files ( )
299+ . create ( req)
300+ . upload_resumable ( stream, "application_pdf" . parse ( ) . unwrap ( ) )
301+ . await
302+ . map_err ( RfdPdfError :: Remote )
303+ }
296304 } ;
297305
298306 vec ! [ response. and_then( |( _, file) | {
0 commit comments