@@ -238,4 +238,49 @@ mod tests {
238
238
time_diff
239
239
) ;
240
240
}
241
+
242
+ #[ tokio:: test]
243
+ #[ cfg( windows) ]
244
+ async fn test_download_pipe_windows_path ( ) {
245
+ init ( ) ;
246
+ let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
247
+ let screenpipe_dir = temp_dir. path ( ) . to_path_buf ( ) ;
248
+
249
+ // Create a source directory with a simple pipe
250
+ let source_dir = temp_dir. path ( ) . join ( "source_pipe" ) ;
251
+ tokio:: fs:: create_dir_all ( & source_dir) . await . unwrap ( ) ;
252
+
253
+ // Create a basic pipe.js file
254
+ tokio:: fs:: write (
255
+ source_dir. join ( "pipe.js" ) ,
256
+ r#"console.log("Hello from Windows pipe test!");"# ,
257
+ )
258
+ . await
259
+ . unwrap ( ) ;
260
+
261
+ // Get the absolute Windows path with backslashes
262
+ let source_path = source_dir. to_str ( ) . unwrap ( ) . replace ( "/" , "\\ " ) ;
263
+ println ! ( "Testing Windows path: {}" , source_path) ;
264
+
265
+ // Try to download the pipe using the Windows path
266
+ let result = download_pipe ( & source_path, screenpipe_dir. clone ( ) ) . await ;
267
+
268
+ // The function should succeed with a Windows path
269
+ assert ! (
270
+ result. is_ok( ) ,
271
+ "Failed to handle Windows path: {:?}" ,
272
+ result. err( )
273
+ ) ;
274
+
275
+ // Verify the pipe was copied correctly
276
+ let pipe_name = source_dir. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
277
+ let dest_path = screenpipe_dir
278
+ . join ( "pipes" )
279
+ . join ( format ! ( "{}_local" , pipe_name) ) ;
280
+ assert ! ( dest_path. exists( ) , "Destination pipe directory not found" ) ;
281
+ assert ! (
282
+ dest_path. join( "pipe.js" ) . exists( ) ,
283
+ "pipe.js not found in destination"
284
+ ) ;
285
+ }
241
286
}
0 commit comments