fix issue when creating repository with relative path index used a wrong repository directory

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1443259 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-02-06 22:49:40 +00:00
parent 53f8581435
commit b978de05ff
1 changed files with 7 additions and 9 deletions

View File

@ -588,7 +588,7 @@ public class DefaultManagedRepositoryAdmin
if ( context != null )
{
log.debug( "skip adding repository indexingContent with id {} as already exists", repository.getId() );
log.debug( "skip creating repository indexingContent with id {} as already exists", repository.getId() );
return context;
}
@ -610,10 +610,8 @@ public class DefaultManagedRepositoryAdmin
try
{
String indexDir = repository.getIndexDirectory();
File managedRepository = new File( repository.getLocation() );
//File managedRepository = new File( repository.getLocation() );
File indexDirectory = null;
if ( StringUtils.isNotBlank( indexDir ) )
@ -622,14 +620,14 @@ public class DefaultManagedRepositoryAdmin
// not absolute so create it in repository directory
if ( !indexDirectory.isAbsolute() )
{
indexDirectory = new File( managedRepository, repository.getIndexDirectory() );
indexDirectory = new File( repositoryDirectory, repository.getIndexDirectory() );
repository.setIndexDirectory( indexDirectory.getAbsolutePath() );
}
}
else
{
indexDirectory = new File( managedRepository, ".indexer" );
if ( !managedRepository.isAbsolute() )
indexDirectory = new File( repositoryDirectory, ".indexer" );
if ( !repositoryDirectory.isAbsolute() )
{
indexDirectory = new File( repositoryDirectory, ".indexer" );
repository.setIndexDirectory( indexDirectory.getAbsolutePath() );
@ -645,9 +643,9 @@ public class DefaultManagedRepositoryAdmin
if ( context == null )
{
context = indexer.addIndexingContext( repository.getId(), repository.getId(), managedRepository,
context = indexer.addIndexingContext( repository.getId(), repository.getId(), repositoryDirectory,
indexDirectory,
managedRepository.toURI().toURL().toExternalForm(),
repositoryDirectory.toURI().toURL().toExternalForm(),
indexDirectory.toURI().toURL().toString(), indexCreators );
context.setSearchable( repository.isScanned() );