aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-03-18 18:45:54 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2015-03-18 18:45:54 +0100
commit558d4f781df61964e0a1503be3bcf6ddcd2188ac (patch)
tree7d765a596a558248de80c7fa6fd8bb38d948f127
parent019c05b33bec9422253562fe92649f66449070de (diff)
downloadsonarqube-558d4f781df61964e0a1503be3bcf6ddcd2188ac.tar.gz
sonarqube-558d4f781df61964e0a1503be3bcf6ddcd2188ac.zip
Fix regression in SourcePersister
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/SourcePersister.java8
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml2
2 files changed, 6 insertions, 4 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/SourcePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/SourcePersister.java
index e27d9eca168..5a86495495d 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/SourcePersister.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/SourcePersister.java
@@ -107,14 +107,16 @@ public class SourcePersister implements ScanPersister {
session.commit();
} else {
// Update only if data_hash has changed or if src_hash is missing (progressive migration)
- if (!dataHash.equals(previousDto.getDataHash()) || !metadata.hash().equals(previousDto.getSrcHash())) {
+ boolean binaryDataUpdated = !dataHash.equals(previousDto.getDataHash());
+ boolean srcHashUpdated = !metadata.hash().equals(previousDto.getSrcHash());
+ if (binaryDataUpdated || srcHashUpdated) {
previousDto
.setBinaryData(data)
.setDataHash(dataHash)
.setSrcHash(metadata.hash())
.setLineHashes(lineHashesAsMd5Hex(inputFile));
- // Optimization do not change updated at when updating src_hash to avoid indexation by E/S
- if (!dataHash.equals(previousDto.getDataHash())) {
+ // Optimization only change updated at when updating binary data to avoid unecessary indexation by E/S
+ if (binaryDataUpdated) {
previousDto.setUpdatedAt(0L);
}
mapper.update(previousDto);
diff --git a/sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml b/sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml
index 49ede1dfb30..061c84eb19d 100644
--- a/sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml
@@ -12,7 +12,7 @@
</select>
<select id="selectHashesForProject" parameterType="string" resultType="org.sonar.core.source.db.FileSourceDto">
- SELECT id, file_uuid as fileUuid, data_hash as dataHash, src_hash as srcHash
+ SELECT id, file_uuid as fileUuid, data_hash as dataHash, src_hash as srcHash, updated_at as updatedAt
FROM file_sources
WHERE project_uuid = #{projectUuid}
</select>