/// Copy the dylib to a new location so it'll be properly reloaded on macOS. Clean-up the old
/// temporary plugin file.
Copy the dylib to a new location so it'll be properly reloaded on macOS. Clean-up the old
temporary plugin file.
Copy the dylib to a new location so it ' ll be properly reloaded on macOS . Clean - up the old temporary plugin file .
fn prepare_load_path(&mut self, path: &Path) -> Result<String, std::io::Error> {
        if let Some(temporary_load_path) = self.temporary_load_path.take() {
            log::info!("Cleaning-up temporary plugin at {}", temporary_load_path);
            std::fs::remove_file(&temporary_load_path)?;
        }
        let load_id = uuid::Uuid::new_v4().to_string();
        let load_path = format!("/tmp/plugin-host-{}", load_id);
        std::fs::copy(path, &load_path)?;
        log::info!("Copied plugin into {}", &load_path);
        self.temporary_load_path = Some(load_path.clone());
        #[cfg(target_os = "macos")]
        {
            log::info!("Tainting the library with install_name_tool. Multiple versions will be loaded at the same time due to macOS limitations.");
            let _ = Command::new("install_name_tool")
                .args(&["-id", &load_id, &load_path])
                .output();
        }
        Ok(load_path)
    }
fn prepare_load_path ( & mut self , path : & Path ) -> Result < String , std :: io :: Error > { if let Some ( temporary_load_path ) = self . temporary_load_path . take ( ) { log :: info ! ( " " temporary_load_path ) ; std :: fs :: remove_file ( & temporary_load_path ) ? ; } let load_id = uuid :: Uuid :: new_v4 ( ) . to_string ( ) ; let load_path = format ! ( " " load_id ) ; std :: fs :: copy ( path , & load_path ) ? ; log :: info ! ( " " load_path ) ; self . temporary_load_path = Some ( load_path . clone ( ) ) ; # [ cfg ( target_os " " ) ] { log :: info ! ( " " ) ; let _ = Command :: new ( " " ) . args ( & [ " " , & load_id , & load_path ] ) . output ( ) ; } Ok ( load_path ) }
Copy the dylib to a new location so it'll be properly reloaded on macOS.
Copy the dylib to a new location so it ' ll be properly reloaded on macOS .
&mut self
path
&Path