Changeset 2249


Ignore:
Timestamp:
10/23/2010 1:35:00 AM (4 years ago)
Author:
lowjoel
Message:

Backported r2150 r2155 and r2161 from trunk: do not throw an out-of-disk space error when erasing unused space. This is triggered by us renaming files even when there is insufficient disk space (apparently NTFS needs space even when renaming filenames to one of the same length.)

Location:
branches/eraser6/6.0
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/6.0

  • branches/eraser6/6.0/Eraser.DefaultPlugins/FileSystems/Ntfs.cs

    r1677 r2249  
    202202            get 
    203203            { 
    204                 return new DateTime(1601, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); 
     204                return new DateTime(1601, 1, 1, 0, 0, 0, 1, DateTimeKind.Utc); 
    205205            } 
    206206        } 
  • branches/eraser6/6.0/Eraser.DefaultPlugins/FileSystems/Windows.cs

    r2158 r2249  
    3636    public abstract class WindowsFileSystem : FileSystem 
    3737    { 
     38        public override void ResetFileTimes(FileSystemInfo info) 
     39        { 
     40            //Reset the file access times: after every rename the file times may change. 
     41            info.SetTimes(MinTimestamp, MinTimestamp, MinTimestamp, MinTimestamp); 
     42        } 
     43 
    3844        public override void DeleteFile(FileInfo info) 
    3945        { 
     
    5157                try 
    5258                { 
    53                     info.CreationTime = info.LastWriteTime = info.LastAccessTime = MinTimestamp; 
     59                    ResetFileTimes(info); 
    5460                    info.MoveTo(newPath); 
    5561                    ++i; 
     
    7379                            //Let the process locking the file release the lock 
    7480                            Thread.Sleep(100); 
     81                            break; 
     82 
     83                        case Win32ErrorCode.DiskFull: 
     84                            //If the disk is full, we can't do anything except manually deleting 
     85                            //the file, break out of this loop. 
     86                            i = FileNameEraseTries; 
    7587                            break; 
    7688 
     
    361373                } 
    362374            } 
     375            finally 
     376            { 
     377                //Reset the file times 
     378                streamInfo.SetTimes(MinTimestamp, created, lastWrite, lastAccess); 
     379            } 
    363380        } 
    364381 
  • branches/eraser6/6.0/Eraser.Manager/FileSystem.cs

    r1883 r2249  
    190190 
    191191        /// <summary> 
     192        /// Resets the created, modified, accessed and last update times for the given 
     193        /// <paramref name="info"/>. 
     194        /// </summary> 
     195        /// <param name="info">The file to reset times.</param> 
     196        public abstract void ResetFileTimes(FileSystemInfo info); 
     197 
     198        /// <summary> 
    192199        /// Securely deletes the file reference from the directory structures 
    193200        /// as well as resetting the Date Created, Date Accessed and Date Modified 
  • branches/eraser6/6.0/Eraser.Util/StreamInfo.cs

    r1677 r2249  
    387387            } 
    388388 
     389            return OpenHandle(mode, iAccess, share, options); 
     390        } 
     391 
     392        internal SafeFileHandle OpenHandle(FileMode mode, uint access, FileShare share, 
     393            FileOptions options) 
     394        { 
    389395            //Sharing mode 
    390396            if ((share & FileShare.Inheritable) != 0) 
     
    408414        } 
    409415 
     416        public void SetTimes(DateTime updateTime, DateTime createdTime, DateTime lastModifiedTime, 
     417            DateTime lastAccessedTime) 
     418        { 
     419            using (SafeFileHandle streamHandle = OpenHandle(FileMode.Open, 
     420                    NativeMethods.FILE_WRITE_ATTRIBUTES, FileShare.ReadWrite, 
     421                    FileOptions.None)) 
     422            { 
     423                ExtensionMethods.IO.SetTimes(streamHandle, updateTime, createdTime, 
     424                    lastModifiedTime, lastAccessedTime); 
     425            } 
     426        } 
     427 
    410428        /// <summary> 
    411429        /// Returns the path as a string. 
Note: See TracChangeset for help on using the changeset viewer.