Changeset 777
- Timestamp:
- 12/10/2008 9:56:02 AM (5 years ago)
- File:
-
- 1 edited
-
branches/eraser6/Manager/Task.cs (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/Manager/Task.cs
r754 r777 92 92 93 93 /// <summary> 94 /// The task which owns this target. 95 /// </summary> 96 public Task Task 97 { 98 get 99 { 100 return task; 101 } 102 internal set 103 { 104 task = value; 105 } 106 } 107 108 /// <summary> 94 109 /// Retrieves the text to display representing this task. 95 110 /// </summary> … … 112 127 /// </summary> 113 128 protected ErasureMethod method = null; 129 130 /// <summary> 131 /// The task object owning this target. 132 /// </summary> 133 private Task task = null; 114 134 } 115 135 … … 171 191 } 172 192 } 173 catch (UnauthorizedAccessException )193 catch (UnauthorizedAccessException e) 174 194 { 175 195 //The system cannot read the file, assume no ADSes for lack of 176 196 //more information. 197 Task.Log.Add(new LogEntry(e.Message, LogLevel.ERROR)); 177 198 } 178 199 } … … 488 509 ref long totalSize) 489 510 { 490 foreach (FileSystemInfo fsInfo in info.GetFileSystemInfos())491 { 492 if (fsInfo is FileInfo)511 try 512 { 513 foreach (FileSystemInfo fsInfo in info.GetFileSystemInfos()) 493 514 { 494 paths.Add(fsInfo.FullName); 495 totalSize += ((FileInfo)fsInfo).Length; 496 GetPathADSes(ref paths, ref totalSize, fsInfo.FullName); 515 if (fsInfo is FileInfo) 516 { 517 paths.Add(fsInfo.FullName); 518 totalSize += ((FileInfo)fsInfo).Length; 519 GetPathADSes(ref paths, ref totalSize, fsInfo.FullName); 520 } 521 else 522 GetRecyclerFiles((DirectoryInfo)fsInfo, ref paths, ref totalSize); 497 523 } 498 else 499 GetRecyclerFiles((DirectoryInfo)fsInfo, ref paths, ref totalSize); 524 } 525 catch (UnauthorizedAccessException e) 526 { 527 Task.Log.Add(new LogEntry(e.Message, LogLevel.ERROR)); 500 528 } 501 529 } … … 511 539 } 512 540 } 541 } 542 543 /// <summary> 544 /// Maintains a collection of erasure targets. 545 /// </summary> 546 [Serializable] 547 public class ErasureTargetsList : IList<ErasureTarget>, ICollection<ErasureTarget>, 548 IEnumerable<ErasureTarget>, ISerializable 549 { 550 #region Constructors 551 internal ErasureTargetsList(Task owner) 552 { 553 this.list = new List<ErasureTarget>(); 554 this.owner = owner; 555 } 556 557 internal ErasureTargetsList(Task owner, int capacity) 558 : this(owner) 559 { 560 list.Capacity = capacity; 561 } 562 563 internal ErasureTargetsList(Task owner, IEnumerable<ErasureTarget> targets) 564 : this(owner) 565 { 566 list.AddRange(targets); 567 } 568 #endregion 569 570 #region Serialization Code 571 ErasureTargetsList(SerializationInfo info, StreamingContext context) 572 { 573 list = (List<ErasureTarget>)info.GetValue("list", typeof(List<ErasureTarget>)); 574 } 575 576 public void GetObjectData(SerializationInfo info, StreamingContext context) 577 { 578 info.AddValue("list", list); 579 } 580 #endregion 581 582 #region IEnumerable<ErasureTarget> Members 583 public IEnumerator<ErasureTarget> GetEnumerator() 584 { 585 return list.GetEnumerator(); 586 } 587 #endregion 588 589 #region IEnumerable Members 590 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() 591 { 592 return list.GetEnumerator(); 593 } 594 #endregion 595 596 #region ICollection<ErasureTarget> Members 597 public void Add(ErasureTarget item) 598 { 599 item.Task = owner; 600 list.Add(item); 601 } 602 603 public void Clear() 604 { 605 list.Clear(); 606 } 607 608 public bool Contains(ErasureTarget item) 609 { 610 return list.Contains(item); 611 } 612 613 public void CopyTo(ErasureTarget[] array, int arrayIndex) 614 { 615 list.CopyTo(array, arrayIndex); 616 } 617 618 public int Count 619 { 620 get 621 { 622 return list.Count; 623 } 624 } 625 626 public bool IsReadOnly 627 { 628 get 629 { 630 return IsReadOnly; 631 } 632 } 633 634 public bool Remove(ErasureTarget item) 635 { 636 return list.Remove(item); 637 } 638 #endregion 639 640 #region IList<ErasureTarget> Members 641 public int IndexOf(ErasureTarget item) 642 { 643 return list.IndexOf(item); 644 } 645 646 public void Insert(int index, ErasureTarget item) 647 { 648 item.Task = owner; 649 list.Insert(index, item); 650 } 651 652 public void RemoveAt(int index) 653 { 654 list.RemoveAt(index); 655 } 656 657 public ErasureTarget this[int index] 658 { 659 get 660 { 661 return list[index]; 662 } 663 set 664 { 665 list[index] = value; 666 } 667 } 668 #endregion 669 670 /// <summary> 671 /// The ownere of this list of targets. 672 /// </summary> 673 public Task Owner 674 { 675 get 676 { 677 return owner; 678 } 679 internal set 680 { 681 owner = value; 682 foreach (ErasureTarget target in list) 683 target.Task = owner; 684 } 685 } 686 687 /// <summary> 688 /// The owner of this list of targets. All targets added to this list 689 /// will have the owner set to this object. 690 /// </summary> 691 private Task owner; 692 693 /// <summary> 694 /// The list bring the data store behind this object. 695 /// </summary> 696 List<ErasureTarget> list; 513 697 } 514 698 … … 518 702 id = (uint)info.GetValue("ID", typeof(uint)); 519 703 name = (string)info.GetValue("Name", typeof(string)); 520 targets = (List<ErasureTarget>)info.GetValue("Targets", typeof(List<ErasureTarget>)); 704 targets = (ErasureTargetsList)info.GetValue("Targets", typeof(ErasureTargetsList)); 705 targets.Owner = this; 521 706 log = (Logger)info.GetValue("Log", typeof(Logger)); 522 707 … … 550 735 public Task() 551 736 { 737 targets = new ErasureTargetsList(this); 552 738 } 553 739 … … 624 810 /// The set of data to erase when this task is executed. 625 811 /// </summary> 626 public List<ErasureTarget>Targets812 public ErasureTargetsList Targets 627 813 { 628 814 get { return targets; } 629 set { targets = value; }630 815 } 631 816 … … 717 902 718 903 private Schedule schedule = Schedule.RunNow; 719 private List<ErasureTarget> targets = new List<ErasureTarget>();904 private ErasureTargetsList targets = null; 720 905 private Logger log = new Logger(); 721 906 }
Note: See TracChangeset
for help on using the changeset viewer.
