protected void updateRepositoryMetadata( ArtifactRepository localRepository,
ArtifactRepository remoteRepository )
throws IOException, XmlPullParserException
{
MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();
Metadata metadata = null;
File metadataFile = new File( localRepository.getBasedir(),
localRepository.pathOfLocalRepositoryMetadata( this, remoteRepository ) );
if ( metadataFile.length() == 0 )
{
if ( !metadataFile.delete() )
{
// sleep for 10ms just in case this is windows holding a file lock
try
{
Thread.sleep( 10 );
}
catch ( InterruptedException e )
{
// ignore
}
metadataFile.delete(); // if this fails, forget about it, we'll try to overwrite it anyway so no need
// to delete on exit
}
}
else if ( metadataFile.exists() )
{
Reader reader = null;
try
{
reader = ReaderFactory.newXmlReader( metadataFile );
metadata = mappingReader.read( reader, false );
}
finally
{
IOUtil.close( reader );
}