@@ -51,8 +51,7 @@ impl InMemorySqliteProvider {
5151
5252 fn get_or_create_db ( db : & mut Option < Connection > ) -> Result < & mut Connection , FsError > {
5353 if db. is_none ( ) {
54- let conn =
55- Connection :: open_in_memory ( ) . map_err ( |e| FsError :: Other ( e. to_string ( ) ) ) ?;
54+ let conn = Connection :: open_in_memory ( ) . map_err ( |e| FsError :: Other ( e. to_string ( ) ) ) ?;
5655 conn. execute_batch ( "PRAGMA busy_timeout = 5000;" )
5756 . map_err ( |e| FsError :: Other ( e. to_string ( ) ) ) ?;
5857 * db = Some ( conn) ;
@@ -111,24 +110,13 @@ impl SessionFsProvider for InMemorySqliteProvider {
111110 if dirs. contains ( path) {
112111 Ok ( FileInfo :: new ( false , true , 0 , now, now) )
113112 } else if let Some ( content) = files. get ( path) {
114- Ok ( FileInfo :: new (
115- true ,
116- false ,
117- content. len ( ) as i64 ,
118- now,
119- now,
120- ) )
113+ Ok ( FileInfo :: new ( true , false , content. len ( ) as i64 , now, now) )
121114 } else {
122115 Err ( FsError :: NotFound ( path. to_string ( ) ) )
123116 }
124117 }
125118
126- async fn mkdir (
127- & self ,
128- path : & str ,
129- recursive : bool ,
130- _mode : Option < i64 > ,
131- ) -> Result < ( ) , FsError > {
119+ async fn mkdir ( & self , path : & str , recursive : bool , _mode : Option < i64 > ) -> Result < ( ) , FsError > {
132120 let mut dirs = self . dirs . lock ( ) . unwrap ( ) ;
133121 if recursive {
134122 let parts: Vec < & str > = path. trim_end_matches ( '/' ) . split ( '/' ) . collect ( ) ;
@@ -181,7 +169,9 @@ impl SessionFsProvider for InMemorySqliteProvider {
181169 if let Some ( rest) = f. strip_prefix ( & prefix) {
182170 if !rest. is_empty ( ) {
183171 if let Some ( name) = rest. split ( '/' ) . next ( ) {
184- entries. entry ( name. to_string ( ) ) . or_insert ( DirEntryKind :: File ) ;
172+ entries
173+ . entry ( name. to_string ( ) )
174+ . or_insert ( DirEntryKind :: File ) ;
185175 }
186176 }
187177 }
@@ -261,21 +251,19 @@ impl SessionFsProvider for InMemorySqliteProvider {
261251 . prepare ( trimmed)
262252 . map_err ( |e| FsError :: Other ( e. to_string ( ) ) ) ?;
263253 let col_count = stmt. column_count ( ) ;
264- let columns: Vec < String > =
265- ( 0 ..col_count) . map ( |i| stmt. column_name ( i) . unwrap ( ) . to_string ( ) ) . collect ( ) ;
254+ let columns: Vec < String > = ( 0 ..col_count)
255+ . map ( |i| stmt. column_name ( i) . unwrap ( ) . to_string ( ) )
256+ . collect ( ) ;
266257 let mut rows = vec ! [ ] ;
267- let mut query_rows = stmt
268- . query ( [ ] )
269- . map_err ( |e| FsError :: Other ( e. to_string ( ) ) ) ?;
258+ let mut query_rows = stmt. query ( [ ] ) . map_err ( |e| FsError :: Other ( e. to_string ( ) ) ) ?;
270259 while let Some ( row) = query_rows
271260 . next ( )
272261 . map_err ( |e| FsError :: Other ( e. to_string ( ) ) ) ?
273262 {
274263 let mut map = HashMap :: new ( ) ;
275264 for ( i, col) in columns. iter ( ) . enumerate ( ) {
276- let val: rusqlite:: types:: Value = row
277- . get ( i)
278- . map_err ( |e| FsError :: Other ( e. to_string ( ) ) ) ?;
265+ let val: rusqlite:: types:: Value =
266+ row. get ( i) . map_err ( |e| FsError :: Other ( e. to_string ( ) ) ) ?;
279267 let json_val = match val {
280268 rusqlite:: types:: Value :: Null => serde_json:: Value :: Null ,
281269 rusqlite:: types:: Value :: Integer ( n) => {
@@ -285,9 +273,9 @@ impl SessionFsProvider for InMemorySqliteProvider {
285273 serde_json:: Number :: from_f64 ( f) . unwrap_or ( 0 . into ( ) ) ,
286274 ) ,
287275 rusqlite:: types:: Value :: Text ( s) => serde_json:: Value :: String ( s) ,
288- rusqlite:: types:: Value :: Blob ( b) => serde_json :: Value :: String (
289- String :: from_utf8_lossy ( & b) . into_owned ( ) ,
290- ) ,
276+ rusqlite:: types:: Value :: Blob ( b) => {
277+ serde_json :: Value :: String ( String :: from_utf8_lossy ( & b) . into_owned ( ) )
278+ }
291279 } ;
292280 map. insert ( col. clone ( ) , json_val) ;
293281 }
@@ -342,14 +330,21 @@ fn session_state_path_sqlite() -> String {
342330}
343331
344332fn sqlite_session_fs_config ( ) -> SessionFsConfig {
345- SessionFsConfig :: new ( "/" , session_state_path_sqlite ( ) , SessionFsConventions :: Posix )
346- . with_capabilities ( SessionFsCapabilities :: new ( ) . with_sqlite ( true ) )
333+ SessionFsConfig :: new (
334+ "/" ,
335+ session_state_path_sqlite ( ) ,
336+ SessionFsConventions :: Posix ,
337+ )
338+ . with_capabilities ( SessionFsCapabilities :: new ( ) . with_sqlite ( true ) )
347339}
348340
349341async fn start_sqlite_client ( ctx : & super :: support:: E2eContext ) -> Client {
350- Client :: start ( ctx. client_options ( ) . with_session_fs ( sqlite_session_fs_config ( ) ) )
351- . await
352- . expect ( "start sqlite client" )
342+ Client :: start (
343+ ctx. client_options ( )
344+ . with_session_fs ( sqlite_session_fs_config ( ) ) ,
345+ )
346+ . await
347+ . expect ( "start sqlite client" )
353348}
354349
355350fn sqlite_session_config (
@@ -370,7 +365,10 @@ async fn should_route_sql_queries_through_the_sessionfs_sqlite_handler() {
370365 ctx. set_default_copilot_user ( ) ;
371366 let session_id = "00000000-0000-4000-8000-000000000201" ;
372367 let sqlite_calls = Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ;
373- let provider = Arc :: new ( InMemorySqliteProvider :: new ( session_id, sqlite_calls. clone ( ) ) ) ;
368+ let provider = Arc :: new ( InMemorySqliteProvider :: new (
369+ session_id,
370+ sqlite_calls. clone ( ) ,
371+ ) ) ;
374372 let client = start_sqlite_client ( ctx) . await ;
375373 let session = client
376374 . create_session (
@@ -395,19 +393,27 @@ async fn should_route_sql_queries_through_the_sessionfs_sqlite_handler() {
395393 ) ;
396394
397395 let calls = sqlite_calls. lock ( ) . unwrap ( ) ;
398- let session_calls: Vec < & SqliteCall > =
399- calls. iter ( ) . filter ( |c| c. session_id == session_id) . collect ( ) ;
396+ let session_calls: Vec < & SqliteCall > = calls
397+ . iter ( )
398+ . filter ( |c| c. session_id == session_id)
399+ . collect ( ) ;
400400 assert ! ( !session_calls. is_empty( ) , "expected sqlite calls" ) ;
401401 assert ! (
402- session_calls. iter( ) . any( |c| c. query. to_uppercase( ) . contains( "CREATE TABLE" ) ) ,
402+ session_calls
403+ . iter( )
404+ . any( |c| c. query. to_uppercase( ) . contains( "CREATE TABLE" ) ) ,
403405 "expected CREATE TABLE"
404406 ) ;
405407 assert ! (
406- session_calls. iter( ) . any( |c| c. query. to_uppercase( ) . contains( "INSERT" ) ) ,
408+ session_calls
409+ . iter( )
410+ . any( |c| c. query. to_uppercase( ) . contains( "INSERT" ) ) ,
407411 "expected INSERT"
408412 ) ;
409413 assert ! (
410- session_calls. iter( ) . any( |c| c. query. to_uppercase( ) . contains( "SELECT" ) ) ,
414+ session_calls
415+ . iter( )
416+ . any( |c| c. query. to_uppercase( ) . contains( "SELECT" ) ) ,
411417 "expected SELECT"
412418 ) ;
413419 assert ! (
0 commit comments