Changeset 905 for branches/eraser6/Manager/DirectExecutor.cs
- Timestamp:
- 4/28/2009 12:13:51 PM (4 years ago)
- File:
-
- 1 edited
-
branches/eraser6/Manager/DirectExecutor.cs (modified) (30 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/Manager/DirectExecutor.cs
r899 r905 46 46 } 47 47 48 p ublic override void Dispose()48 protected override void Dispose(bool disposing) 49 49 { 50 50 thread.Abort(); 51 51 schedulerInterrupt.Set(); 52 schedulerInterrupt.Close(); 53 base.Dispose(disposing); 52 54 } 53 55 … … 58 60 } 59 61 60 public override void AddTask( refTask task)62 public override void AddTask(Task task) 61 63 { 62 64 lock (unusedIdsLock) … … 186 188 if (currentTask == task) 187 189 { 188 currentTask.Cancel led = true;190 currentTask.Canceled = true; 189 191 return; 190 192 } … … 213 215 } 214 216 215 public override List<Task> GetTasks()217 public override ICollection<Task> GetTasks() 216 218 { 217 219 lock (tasksLock) … … 246 248 foreach (uint id in tasks.Keys) 247 249 { 248 Task currentTask = tasks[id];249 currentTask.Executor = this;250 Task task = tasks[id]; 251 task.Executor = this; 250 252 while (id > nextId) 251 253 unusedIds.Add(nextId++); … … 253 255 254 256 //Check if the task is recurring. If it is, check if we missed it. 255 if ( currentTask.Schedule is RecurringSchedule)256 ScheduleTask( currentTask);257 if (task.Schedule is RecurringSchedule) 258 ScheduleTask(task); 257 259 } 258 260 … … 301 303 //Broadcast the task started event. 302 304 task.Queued = false; 303 task.Cancel led = false;305 task.Canceled = false; 304 306 task.OnTaskStarted(new TaskEventArgs(task)); 305 307 OnTaskProcessing(task); … … 329 331 catch (Exception e) 330 332 { 331 task.Log.Add(new LogEntry(e.Message, LogLevel.E RROR));333 task.Log.Add(new LogEntry(e.Message, LogLevel.Error)); 332 334 } 333 335 } 334 336 catch (FatalException e) 335 337 { 336 task.Log.Add(new LogEntry(e.Message, LogLevel.F ATAL));338 task.Log.Add(new LogEntry(e.Message, LogLevel.Fatal)); 337 339 } 338 340 catch (Exception e) 339 341 { 340 task.Log.Add(new LogEntry(e.Message, LogLevel.E RROR));342 task.Log.Add(new LogEntry(e.Message, LogLevel.Error)); 341 343 } 342 344 finally … … 540 542 Environment.OSVersion.Version >= new Version(6, 0)) 541 543 { 542 throw new Exception(S._("The program does not have the required permissions" +543 " to erase the unused space on disk. Run the program as an administrator " +544 throw new UnauthorizedAccessException(S._("The program does not have the required " + 545 "permissions to erase the unused space on disk. Run the program as an administrator " + 544 546 "and retry the operation.")); 545 547 } 546 548 else 547 throw new Exception(S._("The program does not have the required permissions " +549 throw new UnauthorizedAccessException(S._("The program does not have the required permissions " + 548 550 "to erase the unused space on disk")); 549 551 } … … 553 555 task.Log.Add(new LogEntry(S._("The drive which is having its unused space erased " + 554 556 "has disk quotas active. This will prevent the complete erasure of unused " + 555 "space and will pose a security concern"), LogLevel.W ARNING));557 "space and will pose a security concern"), LogLevel.Warning)); 556 558 557 559 //Get the erasure method if the user specified he wants the default. … … 581 583 582 584 lock (currentTask) 583 if (currentTask.Cancel led)585 if (currentTask.Canceled) 584 586 throw new FatalException(S._("The task was cancelled.")); 585 587 } … … 599 601 if (Eraser.Util.File.IsCompressed(info.FullName)) 600 602 Eraser.Util.File.SetCompression(info.FullName, false); 601 602 //Determine the total amount of data that needs to be written.603 long totalSize = method.CalculateEraseDataSize(null, volInfo.TotalFreeSpace);604 603 605 604 //Continue creating files while there is free space. … … 638 637 //Then run the erase task 639 638 method.Erase(stream, long.MaxValue, 640 P RNGManager.GetInstance(ManagerLibrary.Instance.Settings.ActivePRNG),639 PrngManager.GetInstance(ManagerLibrary.Instance.Settings.ActivePrng), 641 640 delegate(long lastWritten, int currentPass) 642 641 { … … 654 653 655 654 lock (currentTask) 656 if (currentTask.Cancel led)655 if (currentTask.Canceled) 657 656 throw new FatalException(S._("The task was cancelled.")); 658 657 } … … 664 663 progress.Event.CurrentItemName = S._("Old resident file system table files"); 665 664 task.OnProgressChanged(progress.Event); 666 fsManager.EraseOldFile systemResidentFiles(volInfo, method, null);665 fsManager.EraseOldFileSystemResidentFiles(volInfo, method, null); 667 666 } 668 667 finally … … 682 681 { 683 682 lock (currentTask) 684 if (currentTask.Cancel led)683 if (currentTask.Canceled) 685 684 throw new FatalException(S._("The task was cancelled.")); 686 685 … … 713 712 { 714 713 //Check if we've been cancelled 715 if (task.Cancel led)714 if (task.Canceled) 716 715 throw new FatalException(S._("The task was cancelled.")); 717 716 … … 723 722 task.Log.Add(new LogEntry(S._("Files in {0} did not have their cluster " + 724 723 "tips erased because it is a hard link or a symbolic link.", 725 info.FullName), LogLevel.I NFORMATION));724 info.FullName), LogLevel.Information)); 726 725 return; 727 726 } … … 731 730 task.Log.Add(new LogEntry(S._("{0} did not have its cluster tips " + 732 731 "erased, because it is a system file", file.FullName), 733 LogLevel.I NFORMATION));732 LogLevel.Information)); 734 733 else if ((file.Attributes & FileAttributes.ReparsePoint) != 0) 735 734 task.Log.Add(new LogEntry(S._("{0} did not have its cluster tips " + 736 735 "erased because it is a hard link or a symbolic link.", 737 file.FullName), LogLevel.I NFORMATION));736 file.FullName), LogLevel.Information)); 738 737 else if ((file.Attributes & FileAttributes.Compressed) != 0 || 739 738 (file.Attributes & FileAttributes.Encrypted) != 0 || … … 742 741 task.Log.Add(new LogEntry(S._("{0} did not have its cluster tips " + 743 742 "erased because it is compressed, encrypted or a sparse file.", 744 file.FullName), LogLevel.I NFORMATION));743 file.FullName), LogLevel.Information)); 745 744 } 746 745 else … … 757 756 task.Log.Add(new LogEntry(S._("{0} did not have its cluster tips erased " + 758 757 "because of the following error: {1}", info.FullName, e.Message), 759 LogLevel.E RROR));758 LogLevel.Error)); 760 759 } 761 760 } … … 768 767 task.Log.Add(new LogEntry(S._("{0} did not have its cluster tips erased " + 769 768 "because of the following error: {1}", info.FullName, e.Message), 770 LogLevel.E RROR));769 LogLevel.Error)); 771 770 } 772 771 catch (IOException e) … … 774 773 task.Log.Add(new LogEntry(S._("{0} did not have its cluster tips erased " + 775 774 "because of the following error: {1}", info.FullName, e.Message), 776 LogLevel.E RROR));775 LogLevel.Error)); 777 776 } 778 777 }; … … 796 795 { 797 796 task.Log.Add(new LogEntry(S._("{0} did not have its cluster tips erased. " + 798 "The error returned was: {1}", files[i], e.Message), LogLevel.E RROR));797 "The error returned was: {1}", files[i], e.Message), LogLevel.Error)); 799 798 } 800 799 finally … … 841 840 842 841 //Erase the file 843 method.Erase(stream, long.MaxValue, P RNGManager.GetInstance(844 ManagerLibrary.Instance.Settings.ActiveP RNG), null);842 method.Erase(stream, long.MaxValue, PrngManager.GetInstance( 843 ManagerLibrary.Instance.Settings.ActivePrng), null); 845 844 } 846 845 finally … … 913 912 task.Log.Add(new LogEntry(S._("The file {0} could not be erased " + 914 913 "because the file was either compressed, encrypted or a sparse file.", 915 info.FullName), LogLevel.E RROR));914 info.FullName), LogLevel.Error)); 916 915 } 917 916 … … 932 931 itemTotal = method.CalculateEraseDataSize(null, strm.Length); 933 932 method.Erase(strm, long.MaxValue, 934 P RNGManager.GetInstance(ManagerLibrary.Instance.Settings.ActivePRNG),933 PrngManager.GetInstance(ManagerLibrary.Instance.Settings.ActivePrng), 935 934 delegate(long lastWritten, int currentPass) 936 935 { … … 947 946 948 947 lock (currentTask) 949 if (currentTask.Cancel led)948 if (currentTask.Canceled) 950 949 throw new FatalException(S._("The task was cancelled.")); 951 950 } … … 967 966 task.Log.Add(new LogEntry(S._("The file {0} could not be erased because the " + 968 967 "file's permissions prevent access to the file.", info.FullName), 969 LogLevel.E RROR));968 LogLevel.Error)); 970 969 } 971 970 catch (FileLoadException) 972 971 { 973 972 task.Log.Add(new LogEntry(S._("The file {0} could not be erased because the " + 974 "file is currently in use.", info.FullName), LogLevel.E RROR));973 "file is currently in use.", info.FullName), LogLevel.Error)); 975 974 } 976 975 finally … … 1066 1065 /// is required by no unused IDs remain. 1067 1066 /// </summary> 1068 private uint nextId = 0;1067 private uint nextId; 1069 1068 1070 1069 /// <summary>
Note: See TracChangeset
for help on using the changeset viewer.
