@@ -434,7 +434,7 @@ fn merge(args: &[String]) -> Result<(), String> {
434434 }
435435 i += 1 ;
436436 }
437- let mut s = Session :: new ( ) . with_fs ( ) . with_default_denoise_models ( ) . with_system_clock ( ) ;
437+ let mut s = file_session ( ) ;
438438 let paths = expand_paths ( & files) ;
439439 let r = s. execute ( "library.import" , & json ! ( { "paths" : paths} ) ) . map_err ( |e| e. to_string ( ) ) ?;
440440 let mut ids: Vec < u64 > = r[ "imported" ] . as_array ( ) . map ( |a| a. iter ( ) . filter_map ( Value :: as_u64) . collect ( ) ) . unwrap_or_default ( ) ;
@@ -712,6 +712,12 @@ fn read_settings(p: &str) -> Result<SettingsFile, String> {
712712 }
713713}
714714
715+ /// The session `render` and `merge` develop files in: with the lens database the desktop app downloaded, when it is
716+ /// there (never fetched from here: scripts and tests stay offline).
717+ fn file_session ( ) -> Session {
718+ Session :: new ( ) . with_fs ( ) . with_default_denoise_models ( ) . with_system_clock ( ) . with_default_lens_database ( )
719+ }
720+
715721fn render ( args : & [ String ] ) -> Result < ( ) , String > {
716722 let mut input = None ;
717723 let mut output = None ;
@@ -750,7 +756,7 @@ fn render(args: &[String]) -> Result<(), String> {
750756 }
751757 let input = input. ok_or ( "render: missing input file" ) ?;
752758 let output = output. ok_or ( "render: missing -o OUTPUT" ) ?;
753- let mut s = Session :: new ( ) . with_fs ( ) . with_default_denoise_models ( ) . with_system_clock ( ) ;
759+ let mut s = file_session ( ) ;
754760 let abs = expand_paths ( std:: slice:: from_ref ( & input) ) ;
755761 let r = s. execute ( "library.import" , & json ! ( { "paths" : abs} ) ) . map_err ( |e| e. to_string ( ) ) ?;
756762 let id = r[ "imported" ] [ 0 ] . as_u64 ( ) . ok_or_else ( || format ! ( "{input}: not a readable photo" ) ) ?;
@@ -845,15 +851,30 @@ fn snapshot(args: &[String]) -> Result<(), String> {
845851 let t0 = Instant :: now ( ) ;
846852 let mut session = match & library {
847853 Some ( dir) => {
848- let mut s =
849- Session :: new ( ) . with_fs ( ) . with_default_denoise_models ( ) . with_system_clock ( ) . with_default_face_models ( ) . with_default_slide_templates ( ) ;
854+ let mut s = Session :: new ( )
855+ . with_fs ( )
856+ . with_default_denoise_models ( )
857+ . with_system_clock ( )
858+ . with_default_face_models ( )
859+ . with_default_lens_database ( )
860+ . with_default_slide_templates ( ) ;
850861 s. open_library ( dir, false ) . map_err ( |e| library_error ( dir, e) ) ?;
851862 s
852863 }
853- None if files. is_empty ( ) => {
854- Session :: with_demo ( ) . with_fs ( ) . with_default_denoise_models ( ) . with_system_clock ( ) . with_default_face_models ( ) . with_default_slide_templates ( )
855- }
856- None => Session :: new ( ) . with_fs ( ) . with_default_denoise_models ( ) . with_system_clock ( ) . with_default_face_models ( ) . with_default_slide_templates ( ) ,
864+ None if files. is_empty ( ) => Session :: with_demo ( )
865+ . with_fs ( )
866+ . with_default_denoise_models ( )
867+ . with_system_clock ( )
868+ . with_default_face_models ( )
869+ . with_default_lens_database ( )
870+ . with_default_slide_templates ( ) ,
871+ None => Session :: new ( )
872+ . with_fs ( )
873+ . with_default_denoise_models ( )
874+ . with_system_clock ( )
875+ . with_default_face_models ( )
876+ . with_default_lens_database ( )
877+ . with_default_slide_templates ( ) ,
857878 } ;
858879 // Apply compute policy before imports or the first scripted query can discover an adapter.
859880 session. execute ( "app.gpu" , & json ! ( { "enabled" : false } ) ) . map_err ( |e| e. to_string ( ) ) ?;
@@ -1107,6 +1128,18 @@ mod raw_files_tests {
11071128 }
11081129}
11091130
1131+ #[ cfg( test) ]
1132+ mod tests {
1133+ /// `render` and `merge` read the lens database the desktop app downloaded, as the desktop does (the same raw
1134+ /// gets the same profile everywhere), but never fetch it.
1135+ #[ test]
1136+ fn render_reads_the_downloaded_lens_database ( ) {
1137+ let s = super :: file_session ( ) ;
1138+ assert_eq ! ( lightcraft_engine:: lens_profiles:: host_dir( ) , lightcraft_engine:: lensfun_download:: default_dir( ) ) ;
1139+ assert ! ( !s. lens_auto_download, "selecting it is not permission to download it" ) ;
1140+ }
1141+ }
1142+
11101143#[ cfg( test) ]
11111144mod import_target_tests {
11121145 use super :: { import_and_select, import_targets, json} ;
0 commit comments