Changeset 1725


Ignore:
Timestamp:
1/30/2010 2:15:30 AM (2 years ago)
Author:
lowjoel
Message:

Fixed progress reporting for FL16KB as we call the erasure method twice so the total amount of data is 32KB, not 16KB. The progress function will then be called beyond 16KB and we get an ArgumentOutOfRange? exception.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser6/Eraser.DefaultPlugins/ErasureMethods/FirstLast16KB.cs

    r1675 r1725  
    113113                    "limited, since this is a self-limiting erasure method.")); 
    114114 
    115             //If the target stream is shorter than 16kb, just forward it to the default 
    116             //function. 
    117             if (strm.Length < dataSize) 
     115            //If the target stream is shorter than or equal to 32kb, just forward it to 
     116            //the default function. 
     117            if (strm.Length < dataSize * 2) 
    118118            { 
    119119                method.Erase(strm, erasureLength, prng, callback); 
     
    121121            } 
    122122 
     123            //We need to intercept the callback function as we run the erasure method 
     124            //twice on two parts of the file. 
     125            ErasureMethodProgressFunction customCallback = 
     126                delegate(long lastWritten, long totalData, int currentPass) 
     127                { 
     128                    callback(lastWritten, dataSize * 2, currentPass); 
     129                }; 
     130 
    123131            //Seek to the beginning and write 16kb. 
    124132            strm.Seek(0, SeekOrigin.Begin); 
    125             method.Erase(strm, dataSize, prng, callback); 
     133            method.Erase(strm, dataSize, prng, callback == null ? null: customCallback); 
    126134 
    127135            //Seek to the end - 16kb, and write. 
    128136            strm.Seek(-dataSize, SeekOrigin.End); 
    129             method.Erase(strm, long.MaxValue, prng, callback); 
     137            method.Erase(strm, long.MaxValue, prng, callback == null ? null : customCallback); 
    130138        } 
    131139 
Note: See TracChangeset for help on using the changeset viewer.