Changeset 1739 for trunk/eraser6


Ignore:
Timestamp:
2/3/2010 12:56:25 AM (2 years ago)
Author:
lowjoel
Message:

Forward port from Eraser 6.0: Various filesystem object target searching improvements.

  • When listing files that need to be erased, always ensure that the file exists before querying its properties e.g. Length or Attributes.
  • When passing reference variables, we don't need to use ref (unless we want to change the reference, but in this case, we aren't)
  • Just like for file system objects, when we get a file or directory from the recycle bin, ensure that it exists and that it isn't a reparse point (otherwise, we can just ignore it)
  • Split files and directory enumeration in the recycle bin targets to remove casts (which are slow)
Location:
trunk/eraser6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser6

  • trunk/eraser6/Eraser.Manager/Task.cs

    r1698 r1739  
    455455                    string adsPath = file + ':' + adsName; 
    456456                    list.Add(adsPath); 
    457                     Util.StreamInfo info = new Util.StreamInfo(adsPath); 
     457                    StreamInfo info = new StreamInfo(adsPath); 
    458458                    totalSize += info.Length; 
    459459                } 
     
    686686                Regex excludePattern = new Regex(regex, RegexOptions.IgnoreCase); 
    687687                foreach (FileInfo file in files) 
    688                     if ((file.Attributes & FileAttributes.ReparsePoint) == 0 && 
     688                    if (file.Exists && 
     689                        (file.Attributes & FileAttributes.ReparsePoint) == 0 && 
    689690                        excludePattern.Matches(file.FullName).Count == 0) 
    690691                    { 
     
    697698                foreach (FileInfo file in files) 
    698699                { 
    699                     if ((file.Attributes & FileAttributes.ReparsePoint) != 0) 
     700                    if (!file.Exists || (file.Attributes & FileAttributes.ReparsePoint) != 0) 
    700701                        continue; 
    701702 
     
    800801                        continue; 
    801802 
    802                     GetRecyclerFiles(dir, ref result, ref totalSize); 
     803                    GetRecyclerFiles(dir, result, ref totalSize); 
    803804                } 
    804805            } 
     
    813814        /// <param name="paths">The list of files to store path information in.</param> 
    814815        /// <param name="totalSize">Receives the total size of the files.</param> 
    815         private void GetRecyclerFiles(DirectoryInfo info, ref List<string> paths, 
     816        private void GetRecyclerFiles(DirectoryInfo info, List<string> paths, 
    816817            ref long totalSize) 
    817818        { 
    818819            try 
    819820            { 
    820                 foreach (FileSystemInfo fsInfo in info.GetFileSystemInfos()) 
     821                foreach (FileInfo fileInfo in info.GetFiles()) 
    821822                { 
    822                     FileInfo fileInfo = fsInfo as FileInfo; 
    823                     if (fileInfo != null) 
    824                     { 
    825                         totalSize += fileInfo.Length; 
    826                         GetPathADSes(paths, out totalSize, fileInfo.FullName); 
    827                         paths.Add(fileInfo.FullName); 
    828                     } 
    829                     else 
    830                         GetRecyclerFiles((DirectoryInfo)fsInfo, ref paths, ref totalSize); 
     823                    if (!fileInfo.Exists || (fileInfo.Attributes & FileAttributes.ReparsePoint) != 0) 
     824                        continue; 
     825 
     826                    totalSize += fileInfo.Length; 
     827                    GetPathADSes(paths, out totalSize, fileInfo.FullName); 
     828                    paths.Add(fileInfo.FullName); 
    831829                } 
     830 
     831                foreach (DirectoryInfo directoryInfo in info.GetDirectories()) 
     832                    if ((directoryInfo.Attributes & FileAttributes.ReparsePoint) == 0) 
     833                        GetRecyclerFiles(directoryInfo, paths, ref totalSize); 
    832834            } 
    833835            catch (UnauthorizedAccessException e) 
Note: See TracChangeset for help on using the changeset viewer.