Changeset 1085 for trunk/eraser6


Ignore:
Timestamp:
6/2/2009 1:57:35 AM (6 years ago)
Author:
lowjoel
Message:

Open handles to files are closed when the file's ADSes are listed for erasure; the file is then sent for erasure anyway but if the file is still locked when it is time to erase, just throw an error message to the log.
fixed #14: Runtime unlocking of files

Location:
trunk/eraser6/Eraser.Manager
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser6/Eraser.Manager/DirectExecutor.cs

    r1082 r1085  
    3333using System.Runtime.Serialization.Formatters.Binary; 
    3434using System.Security.Permissions; 
     35using Eraser.Unlocker; 
    3536 
    3637namespace Eraser.Manager 
     
    875876                catch (FileLoadException) 
    876877                { 
    877                     task.Log.LastSessionEntries.Add(new LogEntry(S._("The file {0} could not be " + 
    878                         "erased because the file is currently in use.", info.FullName), 
    879                         LogLevel.Error)); 
     878                    List<OpenHandle> openHandles = OpenHandle.Items; 
     879                    List<System.Diagnostics.Process> processes = new List<System.Diagnostics.Process>(); 
     880                    foreach (OpenHandle handle in openHandles) 
     881                        if (handle.Path == paths[i]) 
     882                            processes.Add(System.Diagnostics.Process.GetProcessById(handle.ProcessId)); 
     883 
     884                    StringBuilder processStr = new StringBuilder(); 
     885                    foreach (System.Diagnostics.Process process in processes) 
     886                        processStr.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, 
     887                            "{0}, ", process.MainModule.FileName); 
     888 
     889                    task.Log.LastSessionEntries.Add(new LogEntry(S._( 
     890                        "Could not force closure of file \"{0}\" (locked by {1})", 
     891                        paths[i], processStr.ToString().Remove(processStr.Length - 2)), LogLevel.Error)); 
    880892                } 
    881893                finally 
  • trunk/eraser6/Eraser.Manager/Eraser.Manager.csproj

    r1060 r1085  
    6767  </ItemGroup> 
    6868  <ItemGroup> 
     69    <ProjectReference Include="..\Eraser.Unlocker\Eraser.Unlocker.vcproj"> 
     70      <Project>{BCFE7D20-FC82-4BBE-BFE4-7B635D70D238}</Project> 
     71      <Name>Eraser.Unlocker</Name> 
     72    </ProjectReference> 
    6973    <ProjectReference Include="..\Eraser.Util\Eraser.Util.csproj"> 
    7074      <Project>{D083E1A8-3A4C-4683-9B3F-D5FEDE61B9C9}</Project> 
     
    100104  --> 
    101105  <PropertyGroup> 
    102     <PreBuildEvent>csgettext --merge EN,NL "$(ProjectDir)\" Strings 
     106    <PreBuildEvent>call $(SolutionDir)UpdateVersions.bat "$(SolutionDir)\" "$(SolutionDir)Version.cs.in" "$(SolutionDir)Version.cs" 
     107csgettext --merge EN,NL "$(ProjectDir)\" Strings 
    103108if ERRORLEVEL 0 exit 0</PreBuildEvent> 
    104109  </PropertyGroup> 
  • trunk/eraser6/Eraser.Manager/Strings.en.resx

    r1033 r1085  
    178178    <value>The file {0} could not be erased because the file's permissions prevent access to the file.</value> 
    179179  </data> 
    180   <data name="The file {0} could not be erased because the file is currently in use." xml:space="preserve"> 
    181     <value>The file {0} could not be erased because the file is currently in use.</value> 
     180  <data name="Could not force closure of file \&quot;{0}\&quot; (locked by {1})" xml:space="preserve"> 
     181    <value>Could not force closure of file \"{0}\" (locked by {1})</value> 
    182182  </data> 
    183183  <data name="Removing folders..." xml:space="preserve"> 
  • trunk/eraser6/Eraser.Manager/Strings.nl.resx

    r1033 r1085  
    178178    <value>(Untranslated)</value> 
    179179  </data> 
    180   <data name="The file {0} could not be erased because the file is currently in use." xml:space="preserve"> 
     180  <data name="Could not force closure of file \&quot;{0}\&quot; (locked by {1})" xml:space="preserve"> 
    181181    <value>(Untranslated)</value> 
    182182  </data> 
  • trunk/eraser6/Eraser.Manager/Strings.resx

    r1033 r1085  
    178178    <value>The file {0} could not be erased because the file's permissions prevent access to the file.</value> 
    179179  </data> 
    180   <data name="The file {0} could not be erased because the file is currently in use." xml:space="preserve"> 
    181     <value>The file {0} could not be erased because the file is currently in use.</value> 
     180  <data name="Could not force closure of file \&quot;{0}\&quot; (locked by {1})" xml:space="preserve"> 
     181    <value>Could not force closure of file \"{0}\" (locked by {1})</value> 
    182182  </data> 
    183183  <data name="Removing folders..." xml:space="preserve"> 
  • trunk/eraser6/Eraser.Manager/Task.cs

    r1082 r1085  
    2929using Eraser.Util; 
    3030using System.Security.Permissions; 
     31using Eraser.Unlocker; 
    3132 
    3233namespace Eraser.Manager 
     
    352353                } 
    353354            } 
    354             catch (IOException e) 
    355             { 
    356                 //The system cannot open the file, assume no ADSes for lack of 
    357                 //more information. 
    358                 Task.Log.LastSessionEntries.Add(new LogEntry(e.Message, LogLevel.Error)); 
     355            catch (FileLoadException) 
     356            { 
     357                //The system cannot open the file, try to force the file handle to close. 
     358                List<OpenHandle> openHandles = OpenHandle.Items; 
     359                foreach (OpenHandle handle in openHandles) 
     360                    if (handle.Path == file && handle.Close()) 
     361                    { 
     362                        GetPathADSes(list, out totalSize, file); 
     363                        return; 
     364                    } 
    359365            } 
    360366            catch (UnauthorizedAccessException e) 
Note: See TracChangeset for help on using the changeset viewer.