Ignore:
Timestamp:
3/11/2008 5:32:30 AM (6 years ago)
Author:
lowjoel
Message:

Implemented time left for erasures.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/Manager/DirectExecutor.cs

    r213 r219  
    178178        private void EraseFilesystemObject(Task task, Task.FilesystemObject target) 
    179179        { 
    180             List<string> paths = target.GetPaths(); 
     180            //Retrieve the list of files to erase. 
     181            long totalSize = 0; 
     182            List<string> paths = target.GetPaths(out totalSize); 
    181183            TaskProgressEventArgs eventArgs = new TaskProgressEventArgs(task, 0, 0); 
    182184 
     
    185187            if (method == ErasureMethodManager.Default) 
    186188                method = ErasureMethodManager.GetInstance(Globals.Settings.DefaultFileErasureMethod); 
     189 
     190            //Calculate the total amount of data required to finish the wipe. This 
     191            //value is just the total about of data to be erased multiplied by 
     192            //number of passes 
     193            totalSize *= method.Passes; 
     194 
     195            //Record the start of the erasure pass so we can calculate speed of erasures 
     196            long totalLeft = totalSize; 
     197            long overallWriteSpeed = 0; 
     198            DateTime startTime = DateTime.Now; 
    187199 
    188200            //Iterate over every path, and erase the path. 
     
    230242                        delegate(float currentProgress, int currentPass) 
    231243                        { 
     244                            long amountWritten = (long)(currentProgress * (info.Length * method.Passes)); 
     245                            if (overallWriteSpeed != 0) 
     246                                eventArgs.timeLeft = (int)((totalLeft - amountWritten) / 
     247                                    overallWriteSpeed); 
     248                            else if (amountWritten != 0 && (DateTime.Now - startTime).TotalSeconds != 0) 
     249                                overallWriteSpeed = (long)(amountWritten / 
     250                                    (DateTime.Now - startTime).TotalSeconds); 
     251 
    232252                            eventArgs.currentPass = currentPass; 
    233253                            eventArgs.currentItemProgress = (int) 
     
    239259                    ); 
    240260 
     261                    //Update the speed-influencing statistics. 
     262                    totalLeft -= info.Length * method.Passes; 
     263                    overallWriteSpeed = (long)((totalSize - totalLeft) / 
     264                        (DateTime.Now - startTime).TotalSeconds); 
     265 
    241266                    //Set the length of the file to 0. 
    242267                    strm.Seek(0, SeekOrigin.Begin); 
Note: See TracChangeset for help on using the changeset viewer.