@@ -73,9 +73,20 @@ fn run_mediainfo( file: &PathBuf ) -> Result<serde_json::Value, String>
7373 let link_path = temp_dir. join ( format ! ( "tempname{}" , extension) ) ;
7474
7575 // (symlink wasn't reliable on Windows WSL, so we'll use hard link instead)
76- tracing:: debug!( "Creating temp hard link from {:?} to {:?}" , file, link_path) ;
76+ // However, hard links fail across filesystem boundaries, so we fall back to symlink
77+ tracing:: debug!( "Creating temp link from {:?} to {:?}" , file, link_path) ;
7778 std:: fs:: create_dir ( & temp_dir) . map_err ( |e| e. to_string ( ) ) ?;
78- std:: fs:: hard_link ( file, & link_path) . map_err ( |e| e. to_string ( ) ) ?;
79+
80+ // Try hardlink first, fallback to symlink if it fails (e.g., cross-device link)
81+ match std:: fs:: hard_link ( file, & link_path) {
82+ Ok ( _) => {
83+ tracing:: debug!( "Created hard link successfully" ) ;
84+ } ,
85+ Err ( e) => {
86+ tracing:: debug!( "Hard link failed ({}), falling back to symlink" , e) ;
87+ std:: os:: unix:: fs:: symlink ( file, & link_path) . map_err ( |e| e. to_string ( ) ) ?;
88+ }
89+ }
7990
8091 // Run mediainfo
8192 let cmd = & mut Command :: new ( "mediainfo" ) ;
@@ -84,8 +95,8 @@ fn run_mediainfo( file: &PathBuf ) -> Result<serde_json::Value, String>
8495 tracing:: debug!( "Exec: {:?}" , cmd) ;
8596 let mediainfo_res = cmd. output ( ) ;
8697
87- // Remove temp hardlink
88- tracing:: debug!( "Removing temp hard link and directory ({:?})" , link_path) ;
98+ // Remove temp link ( hardlink or symlink) and directory
99+ tracing:: debug!( "Removing temp link and directory ({:?})" , link_path) ;
89100 if let Err ( e) = std:: fs:: remove_file ( & link_path) {
90101 tracing:: error!( "Failed to remove temporary link file: {}" , e) ;
91102 } else {
0 commit comments