Changeset 2663
- Timestamp:
- 5/24/2012 7:31:56 AM (12 months ago)
- Location:
- branches/eraser6/6.0
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
Eraser.Manager/DirectExecutor.cs (modified) (1 diff)
-
Eraser.Manager/Task.cs (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/6.0
- Property svn:mergeinfo changed
/trunk/eraser merged: 2653-2654,2656-2658,2662
- Property svn:mergeinfo changed
-
branches/eraser6/6.0/Eraser.Manager/DirectExecutor.cs
r2633 r2663 833 833 fsManager.DeleteFolder(info); 834 834 } 835 catch (DirectoryNotFoundException) 836 { 837 task.Log.LastSessionEntries.Add(new LogEntry( 838 S._("The folder {0} was not erased because the containing " + 839 "directory was deleted before it could be erased.", 840 info.FullName), 841 LogLevel.Information)); 842 } 835 843 catch (UnauthorizedAccessException) 836 844 { -
branches/eraser6/6.0/Eraser.Manager/Task.cs
r2575 r2663 402 402 protected void GetPathADSes(ICollection<string> list, out long totalSize, string file) 403 403 { 404 int attempts = 0; 405 GetPathADSes(list, out totalSize, file, ref attempts); 406 } 407 408 private void GetPathADSes(ICollection<string> list, out long totalSize, string file, ref int attempts) 409 { 404 410 totalSize = 0; 405 411 … … 418 424 } 419 425 } 426 catch (FileNotFoundException) 427 { 428 } 420 429 catch (FileLoadException) 421 430 { … … 424 433 throw; 425 434 435 bool handlesClosed = false; 426 436 foreach (OpenHandle handle in OpenHandle.Items) 427 437 if (handle.Path == file && handle.Close()) 438 handlesClosed = true; 439 440 if (handlesClosed) 441 { 442 //Retry closing the file 10 times. If we can't do that, we should abort 443 //since we may not be able to get the process information of processes 444 //running with higher privileges. 445 if (++attempts <= 10) 428 446 { 429 GetPathADSes(list, out totalSize, file );447 GetPathADSes(list, out totalSize, file, ref attempts); 430 448 return; 431 449 } 450 else 451 throw; 452 } 432 453 } 433 454 catch (UnauthorizedAccessException e) … … 573 594 FileInfo fileInfo = new FileInfo(Path); 574 595 575 if (fileInfo.Exists)596 try 576 597 { 577 598 GetPathADSes(result, out totalSize, Path); 578 599 totalSize += fileInfo.Length; 579 } 580 581 result.Add(Path); 600 result.Add(Path); 601 } 602 catch (FileLoadException) 603 { 604 Task.Log.LastSessionEntries.Add(new LogEntry( 605 S._("Could not list the Alternate Data Streams for file {0} " + 606 "because the file is being used by another process. The file " + 607 "will not be erased.", fileInfo.FullName), 608 LogLevel.Error)); 609 } 610 catch (FileNotFoundException) 611 { 612 } 613 catch (DirectoryNotFoundException) 614 { 615 } 616 582 617 return result; 583 618 } … … 642 677 excludePattern.Matches(file.FullName).Count == 0) 643 678 { 644 totalSize += file.Length; 645 long adsesSize = 0; 646 GetPathADSes(result, out adsesSize, file.FullName); 647 totalSize += adsesSize; 648 result.Add(file.FullName); 679 try 680 { 681 totalSize += file.Length; 682 long adsesSize = 0; 683 GetPathADSes(result, out adsesSize, file.FullName); 684 totalSize += adsesSize; 685 result.Add(file.FullName); 686 } 687 catch (FileNotFoundException) 688 { 689 Task.Log.LastSessionEntries.Add(new LogEntry( 690 S._("The file {0} was not erased because it was deleted " + 691 "before it could be erased.", file.FullName), 692 LogLevel.Information)); 693 } 694 catch (DirectoryNotFoundException) 695 { 696 Task.Log.LastSessionEntries.Add(new LogEntry( 697 S._("The file {0} was not erased because the containing " + 698 "directory was deleted before it could be erased.", 699 file.FullName), 700 LogLevel.Information)); 701 } 702 catch (FileLoadException) 703 { 704 Task.Log.LastSessionEntries.Add(new LogEntry( 705 S._("Could not list the Alternate Data Streams for file {0} " + 706 "because the file is being used by another process. The " + 707 "file will not be erased.", file.FullName), 708 LogLevel.Error)); 709 } 649 710 } 650 711 } … … 655 716 continue; 656 717 657 //Get the size of the file and its ADSes 658 totalSize += file.Length; 659 long adsesSize = 0; 660 GetPathADSes(result, out adsesSize, file.FullName); 661 totalSize += adsesSize; 662 663 //Append this file to the list of files to erase. 664 result.Add(file.FullName); 718 try 719 { 720 //Get the size of the file and its ADSes 721 totalSize += file.Length; 722 long adsesSize = 0; 723 GetPathADSes(result, out adsesSize, file.FullName); 724 totalSize += adsesSize; 725 726 //Append this file to the list of files to erase. 727 result.Add(file.FullName); 728 } 729 catch (FileNotFoundException) 730 { 731 Task.Log.LastSessionEntries.Add(new LogEntry( 732 S._("The file {0} was not erased because it was deleted " + 733 "before it could be erased.", file.FullName), 734 LogLevel.Information)); 735 } 736 catch (DirectoryNotFoundException) 737 { 738 Task.Log.LastSessionEntries.Add(new LogEntry( 739 S._("The file {0} was not erased because the containing " + 740 "directory was deleted before it could be erased.", 741 file.FullName), 742 LogLevel.Information)); 743 } 744 catch (FileLoadException) 745 { 746 Task.Log.LastSessionEntries.Add(new LogEntry( 747 S._("Could not list the Alternate Data Streams for file {0} " + 748 "because the file is being used by another process. The " + 749 "file will not be erased.", file.FullName), 750 LogLevel.Error)); 751 } 665 752 } 666 753 … … 779 866 foreach (FileInfo fileInfo in info.GetFiles()) 780 867 { 781 if (!fileInfo.Exists || (fileInfo.Attributes & FileAttributes.ReparsePoint) != 0) 782 continue; 783 784 totalSize += fileInfo.Length; 785 GetPathADSes(paths, out totalSize, fileInfo.FullName); 786 paths.Add(fileInfo.FullName); 868 try 869 { 870 if (!fileInfo.Exists || (fileInfo.Attributes & FileAttributes.ReparsePoint) != 0) 871 continue; 872 873 totalSize += fileInfo.Length; 874 GetPathADSes(paths, out totalSize, fileInfo.FullName); 875 paths.Add(fileInfo.FullName); 876 } 877 catch (FileNotFoundException) 878 { 879 Task.Log.LastSessionEntries.Add(new LogEntry( 880 S._("The file {0} was not erased because it was deleted " + 881 "before it could be erased.", fileInfo.FullName), 882 LogLevel.Information)); 883 } 884 catch (DirectoryNotFoundException) 885 { 886 Task.Log.LastSessionEntries.Add(new LogEntry( 887 S._("The file {0} was not erased because the containing " + 888 "directory was deleted before it could be erased.", 889 fileInfo.FullName), 890 LogLevel.Information)); 891 } 892 catch (FileLoadException) 893 { 894 Task.Log.LastSessionEntries.Add(new LogEntry( 895 S._("Could not list the Alternate Data Streams for file {0} " + 896 "because the file is being used by another process. The " + 897 "file will not be erased.", fileInfo.FullName), 898 LogLevel.Error)); 899 } 787 900 } 788 901
Note: See TracChangeset
for help on using the changeset viewer.
