@@ -51,9 +51,9 @@ impl FileSystem {
5151 . file_modified_since_in_db ( app_state, path, since)
5252 . await
5353 }
54- ( Err ( e) , _) => {
55- Err ( e ) . with_context ( || format ! ( "Unable to read local file metadata for {path:?}" ) )
56- }
54+ ( Err ( e) , _) => Err ( e ) . with_context ( || {
55+ format ! ( "Unable to read local file metadata for {}" , path . display ( ) )
56+ } ) ,
5757 }
5858 }
5959
@@ -64,8 +64,12 @@ impl FileSystem {
6464 priviledged : bool ,
6565 ) -> anyhow:: Result < String > {
6666 let bytes = self . read_file ( app_state, path, priviledged) . await ?;
67- String :: from_utf8 ( bytes)
68- . with_context ( || format ! ( "The file at {path:?} contains invalid UTF8 characters" ) )
67+ String :: from_utf8 ( bytes) . with_context ( || {
68+ format ! (
69+ "The file at {} contains invalid UTF8 characters" ,
70+ path. display( )
71+ )
72+ } )
6973 }
7074
7175 /**
@@ -78,7 +82,11 @@ impl FileSystem {
7882 priviledged : bool ,
7983 ) -> anyhow:: Result < Vec < u8 > > {
8084 let local_path = self . safe_local_path ( app_state, path, priviledged) ?;
81- log:: debug!( "Reading file {path:?} from {local_path:?}" ) ;
85+ log:: debug!(
86+ "Reading file {} from {}" ,
87+ path. display( ) ,
88+ local_path. display( )
89+ ) ;
8290 let local_result = tokio:: fs:: read ( & local_path) . await ;
8391 match ( local_result, & self . db_fs_queries ) {
8492 ( Ok ( f) , _) => Ok ( f) ,
@@ -90,7 +98,9 @@ impl FileSystem {
9098 status : actix_web:: http:: StatusCode :: NOT_FOUND ,
9199 }
92100 . into ( ) ) ,
93- ( Err ( e) , _) => Err ( e) . with_context ( || format ! ( "Unable to read local file {path:?}" ) ) ,
101+ ( Err ( e) , _) => {
102+ Err ( e) . with_context ( || format ! ( "Unable to read local file {}" , path. display( ) ) )
103+ }
94104 }
95105 }
96106
@@ -104,14 +114,16 @@ impl FileSystem {
104114 // Templates requests are always made to the static TEMPLATES_DIR, because this is where they are stored in the database
105115 // but when serving them from the filesystem, we need to serve them from the `SQLPAGE_CONFIGURATION_DIRECTORY/templates` directory
106116 if let Ok ( template_path) = path. strip_prefix ( TEMPLATES_DIR ) {
107- let normalized = [
108- & app_state. config . configuration_directory ,
109- Path :: new ( "templates" ) ,
110- template_path,
111- ]
112- . iter ( )
113- . collect ( ) ;
114- log:: trace!( "Normalizing template path {path:?} to {normalized:?}" ) ;
117+ let normalized = app_state
118+ . config
119+ . configuration_directory
120+ . join ( "templates" )
121+ . join ( template_path) ;
122+ log:: trace!(
123+ "Normalizing template path {} to {}" ,
124+ path. display( ) ,
125+ normalized. display( )
126+ ) ;
115127 return Ok ( normalized) ;
116128 }
117129 } else {
@@ -149,7 +161,10 @@ impl FileSystem {
149161
150162 // If not in local fs and we have db_fs, check database
151163 if !local_exists {
152- log:: debug!( "File {path:?} not found in local filesystem, checking database" ) ;
164+ log:: debug!(
165+ "File {} not found in local filesystem, checking database" ,
166+ path. display( )
167+ ) ;
153168 if let Some ( db_fs) = & self . db_fs_queries {
154169 return db_fs. file_exists ( app_state, path) . await ;
155170 }
@@ -245,9 +260,11 @@ impl DbFsQueries {
245260 . bind ( since)
246261 . bind ( path. display ( ) . to_string ( ) ) ;
247262 log:: trace!(
248- "Checking if file {path:? } was modified since {since } by executing query: \n \
263+ "Checking if file {} was modified since {} by executing query: \n \
249264 {}\n \
250265 with parameters: {:?}",
266+ path. display( ) ,
267+ since,
251268 self . was_modified. sql( ) ,
252269 ( since, path)
253270 ) ;
@@ -256,7 +273,10 @@ impl DbFsQueries {
256273 . await
257274 . map ( |modified| modified == Some ( ( 1 , ) ) )
258275 . with_context ( || {
259- format ! ( "Unable to check when {path:?} was last modified in the database" )
276+ format ! (
277+ "Unable to check when {} was last modified in the database" ,
278+ path. display( )
279+ )
260280 } )
261281 }
262282
@@ -278,7 +298,7 @@ impl DbFsQueries {
278298 . into ( ) )
279299 }
280300 } )
281- . with_context ( || format ! ( "Unable to read {path:? } from the database" ) )
301+ . with_context ( || format ! ( "Unable to read {} from the database" , path . display ( ) ) )
282302 }
283303
284304 async fn file_exists ( & self , app_state : & AppState , path : & Path ) -> anyhow:: Result < bool > {
@@ -287,17 +307,21 @@ impl DbFsQueries {
287307 . query_as :: < ( i32 , ) > ( )
288308 . bind ( path. display ( ) . to_string ( ) ) ;
289309 log:: trace!(
290- "Checking if file {path:? } exists by executing query: \n \
310+ "Checking if file {} exists by executing query: \n \
291311 {}\n \
292312 with parameters: {:?}",
313+ path. display( ) ,
293314 self . exists. sql( ) ,
294315 ( path, )
295316 ) ;
296317 let result = query. fetch_optional ( & app_state. db . connection ) . await ;
297318 log:: debug!( "DB File exists result: {result:?}" ) ;
298- result
299- . map ( |result| result. is_some ( ) )
300- . with_context ( || format ! ( "Unable to check if {path:?} exists in the database" ) )
319+ result. map ( |result| result. is_some ( ) ) . with_context ( || {
320+ format ! (
321+ "Unable to check if {} exists in the database" ,
322+ path. display( )
323+ )
324+ } )
301325 }
302326}
303327
0 commit comments