summaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2013-11-15 00:41:06 +0000
committerOlivier Lamy <olamy@apache.org>2013-11-15 00:41:06 +0000
commit76b43a92541e7d209908023d02a94896e65588d3 (patch)
tree5c5f996709aa4e485932f13d6eb1b48902616fe5 /archiva-modules/archiva-base
parentd8afa32103ea063ebe959a66fa968dc3cebc7775 (diff)
downloadarchiva-76b43a92541e7d209908023d02a94896e65588d3.tar.gz
archiva-76b43a92541e7d209908023d02a94896e65588d3.zip
ignore files part of index directory when scanning
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1542140 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base')
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/functors/ConsumerWantsFilePredicate.java37
-rw-r--r--archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryContentConsumers.java2
-rw-r--r--archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryScannerInstance.java2
3 files changed, 35 insertions, 6 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/functors/ConsumerWantsFilePredicate.java b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/functors/ConsumerWantsFilePredicate.java
index 7846d1ecb..e52962c79 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/functors/ConsumerWantsFilePredicate.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-api/src/main/java/org/apache/archiva/consumers/functors/ConsumerWantsFilePredicate.java
@@ -21,16 +21,18 @@ package org.apache.archiva.consumers.functors;
import java.util.List;
+import org.apache.archiva.admin.model.beans.ManagedRepository;
import org.apache.commons.collections.Predicate;
import org.apache.commons.io.FilenameUtils;
import org.apache.archiva.common.utils.BaseFile;
import org.apache.archiva.consumers.RepositoryContentConsumer;
+import org.apache.commons.lang.StringUtils;
import org.apache.tools.ant.types.selectors.SelectorUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
- * ConsumerWantsFilePredicate
- *
- *
+ * ConsumerWantsFilePredicate
*/
public class ConsumerWantsFilePredicate
implements Predicate
@@ -43,6 +45,23 @@ public class ConsumerWantsFilePredicate
private long changesSince = 0;
+ private ManagedRepository managedRepository;
+
+ private Logger logger = LoggerFactory.getLogger( getClass() );
+
+ /**
+ * @deprecated use constructor with ManagedRepository
+ */
+ public ConsumerWantsFilePredicate()
+ {
+ // no-op
+ }
+
+ public ConsumerWantsFilePredicate( ManagedRepository managedRepository )
+ {
+ this.managedRepository = managedRepository;
+ }
+
public boolean evaluate( Object object )
{
boolean satisfies = false;
@@ -53,7 +72,7 @@ public class ConsumerWantsFilePredicate
if ( wantsFile( consumer, FilenameUtils.separatorsToUnix( basefile.getRelativePath() ) ) )
{
satisfies = true;
-
+
// regardless of the timestamp, we record that it was wanted so it doesn't get counted as invalid
wantedFileCount++;
@@ -114,6 +133,16 @@ public class ConsumerWantsFilePredicate
}
}
+ if ( managedRepository != null )
+ {
+ String indexDirectory = managedRepository.getIndexDirectory();
+ if ( StringUtils.startsWith( relativePath, indexDirectory ) )
+ {
+ logger.debug( "ignore file {} part of the index directory {}", relativePath, indexDirectory );
+ return false;
+ }
+ }
+
// Now test includes.
for ( String pattern : consumer.getIncludes() )
{
diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryContentConsumers.java b/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryContentConsumers.java
index 31bb11eb3..d899455e0 100644
--- a/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryContentConsumers.java
+++ b/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryContentConsumers.java
@@ -283,7 +283,7 @@ public class RepositoryContentConsumers
// yuck. In case you can't read this, it says
// "process the file if the consumer has it in the includes list, and not in the excludes list"
BaseFile baseFile = new BaseFile( repository.getLocation(), localFile );
- ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate();
+ ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate( repository );
predicate.setBasefile( baseFile );
predicate.setCaseSensitive( false );
diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryScannerInstance.java b/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryScannerInstance.java
index 4748e023a..88638ba00 100644
--- a/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryScannerInstance.java
+++ b/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/RepositoryScannerInstance.java
@@ -91,7 +91,7 @@ public class RepositoryScannerInstance
consumerProcessFile.setConsumerTimings( consumerTimings );
consumerProcessFile.setConsumerCounts( consumerCounts );
- this.consumerWantsFile = new ConsumerWantsFilePredicate();
+ this.consumerWantsFile = new ConsumerWantsFilePredicate( repository );
stats = new RepositoryScanStatistics();
stats.setRepositoryId( repository.getId() );