mirror of https://github.com/apache/maven.git
Safer deletes
This commit is contained in:
parent
9a9cf059fd
commit
33c53dcae8
|
@ -141,7 +141,19 @@ public class DefaultRepositoryMetadataManager
|
|||
// delete the local copy so the old details aren't used.
|
||||
if ( file.exists() )
|
||||
{
|
||||
file.delete();
|
||||
if ( !file.delete() )
|
||||
{
|
||||
// sleep for 10ms just in case this is windows holding a file lock
|
||||
try
|
||||
{
|
||||
Thread.sleep( 10 );
|
||||
}
|
||||
catch ( InterruptedException ie )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
file.delete(); // if this fails, forget about it
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( TransferFailedException e )
|
||||
|
@ -448,7 +460,19 @@ public class DefaultRepositoryMetadataManager
|
|||
// delete the local copy so the old details aren't used.
|
||||
if ( file.exists() )
|
||||
{
|
||||
file.delete();
|
||||
if ( !file.delete() )
|
||||
{
|
||||
// sleep for 10ms just in case this is windows holding a file lock
|
||||
try
|
||||
{
|
||||
Thread.sleep( 10 );
|
||||
}
|
||||
catch ( InterruptedException ie )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
file.delete(); // if this fails, forget about it
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -505,7 +505,10 @@ public class DefaultWagonManager
|
|||
{
|
||||
FileUtils.copyFile( temp, destination );
|
||||
|
||||
temp.delete();
|
||||
if ( !temp.delete() )
|
||||
{
|
||||
temp.deleteOnExit();
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
@ -647,14 +650,10 @@ public class DefaultWagonManager
|
|||
for ( File file : files )
|
||||
{
|
||||
// really don't care if it failed here only log warning
|
||||
try
|
||||
if ( !file.delete() )
|
||||
{
|
||||
file.delete();
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
logger.warn( "skip failed to delete temporary file : " + file.getAbsolutePath() + " , message "
|
||||
+ e.getMessage() );
|
||||
logger.warn( "skip failed to delete temporary file : " + file.getAbsolutePath() );
|
||||
file.deleteOnExit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -730,10 +729,13 @@ public class DefaultWagonManager
|
|||
File checksumFile = new File( destination + checksumFileExtension );
|
||||
if ( checksumFile.exists() )
|
||||
{
|
||||
checksumFile.delete();
|
||||
checksumFile.delete(); // ignore if failed as we will overwrite
|
||||
}
|
||||
FileUtils.copyFile( tempChecksumFile, checksumFile );
|
||||
tempChecksumFile.delete();
|
||||
if ( !tempChecksumFile.delete() )
|
||||
{
|
||||
tempChecksumFile.deleteOnExit();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue