@@ -223,65 +223,6 @@ pub(crate) fn tempdirectory() -> Result<TempDir> {
223223 return tempdir ( ) . map_err ( Error :: IoError ) ;
224224}
225225
226- #[ allow( unused) ]
227- #[ cfg( target_os = "wasi" ) ]
228- pub fn wasm_remove_dir_all < P : AsRef < std:: path:: Path > > ( path : P ) -> Result < ( ) > {
229- for entry in std:: fs:: read_dir ( & path) ? {
230- let entry = entry?;
231- let entry_path = entry. path ( ) ;
232- // List initial entries for debugging
233- eprintln ! ( "Initial entry: {}" , entry_path. display( ) ) ;
234- if entry_path. is_file ( ) || entry_path. is_symlink ( ) {
235- eprintln ! ( "Removing file {}" , entry_path. display( ) ) ;
236- std:: fs:: remove_file ( & entry_path) . map_err ( |e| {
237- eprintln ! ( "Failed to remove file {}: {}" , entry_path. display( ) , e) ;
238- e
239- } ) ?;
240- } else if entry_path. is_dir ( ) {
241- eprintln ! ( "Removing directory: {}" , entry_path. display( ) ) ;
242- wasm_remove_dir_all ( & entry_path) . map_err ( |e| {
243- eprintln ! ( "Failed to remove directory {}: {}" , entry_path. display( ) , e) ;
244- e
245- } ) ?;
246- }
247- }
248-
249- // List remaining entries if the directory is still not empty
250- if let Ok ( entries) = std:: fs:: read_dir ( & path) {
251- for entry in entries {
252- if let Ok ( entry) = entry {
253- eprintln ! ( "Remaining entry before removal: {}" , entry. path( ) . display( ) ) ;
254- }
255- }
256- }
257-
258- // Retry removing the directory if it fails
259- let mut retries = 3 ;
260- while retries > 0 {
261- match std:: fs:: remove_dir_all ( & path) {
262- Ok ( _) => return Ok ( ( ) ) ,
263- Err ( e) => {
264- eprintln ! (
265- "Failed to remove directory {}: {}. Retries left: {}" ,
266- path. as_ref( ) . display( ) ,
267- e,
268- retries - 1
269- ) ;
270- retries -= 1 ;
271- std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 100 ) ) ;
272- }
273- }
274- }
275-
276- Err ( std:: io:: Error :: new (
277- std:: io:: ErrorKind :: Other ,
278- format ! (
279- "Failed to remove directory {} after retries" ,
280- path. as_ref( ) . display( )
281- ) ,
282- ) ) ?
283- }
284-
285226/// Convert a URI to a file path using PathBuf for better path handling.
286227#[ cfg( feature = "file_io" ) ]
287228pub fn uri_to_path ( uri : & str , manifest_label : Option < & str > ) -> PathBuf {
0 commit comments