Changeset 1668 for trunk/eraser6


Ignore:
Timestamp:
1/25/2010 4:12:10 AM (5 years ago)
Author:
lowjoel
Message:

Fixed ArgumentOutOfRangeException? when erasing free space using an erasure method containing more than 1 pass.

  • Added checks to the ProgressManager? class to ensure that the Progress property will never exceed 1.0
  • When computing the total amount of data needed to be written to the disk, take into account the number of passes.
Location:
trunk/eraser6/Eraser.Manager
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser6/Eraser.Manager/DirectExecutor.cs

    r1665 r1668  
    443443                        //Set the length of the file to be the amount of free space left 
    444444                        //or the maximum size of one of these dumps. 
    445                         mainProgress.Total = mainProgress.Completed + volInfo.AvailableFreeSpace; 
     445                        mainProgress.Total = mainProgress.Completed + 
     446                            method.CalculateEraseDataSize(null, volInfo.AvailableFreeSpace); 
    446447                        long streamLength = Math.Min(ErasureMethod.FreeSpaceFileUnit, 
    447448                            mainProgress.Total); 
  • trunk/eraser6/Eraser.Manager/ProgressManager.cs

    r1515 r1668  
    100100        public long Completed 
    101101        { 
    102             get; 
    103             set; 
     102            get 
     103            { 
     104                return completed; 
     105            } 
     106            set 
     107            { 
     108                if (value > Total) 
     109                    throw new ArgumentOutOfRangeException("value", value, "The Completed " + 
     110                        "property of the Progress Manager cannot exceed the total work units for " + 
     111                        "the task."); 
     112 
     113                completed = value; 
     114            } 
    104115        } 
    105116 
     
    109120        public long Total 
    110121        { 
    111             get; 
    112             set; 
     122            get 
     123            { 
     124                return Total; 
     125            } 
     126            set 
     127            { 
     128                if (value < Completed) 
     129                    throw new ArgumentOutOfRangeException("value", value, "The Total property " + 
     130                        "of the Progress Manager must be greater than or equal to the completed " + 
     131                        "work units for the task."); 
     132 
     133                Total = value; 
     134            } 
    113135        } 
    114136 
     
    172194        /// </summary> 
    173195        private int lastSpeed; 
     196 
     197        /// <summary> 
     198        /// The backing field for <see cref="Completed"/> 
     199        /// </summary> 
     200        private long completed; 
     201 
     202        /// <summary> 
     203        /// The backing field for <see cref="Total"/> 
     204        /// </summary> 
     205        private long total; 
    174206    } 
    175207 
Note: See TracChangeset for help on using the changeset viewer.