]> source.dussan.org Git - sonarqube.git/commitdiff
Fix regression in SourcePersister
authorJulien HENRY <julien.henry@sonarsource.com>
Wed, 18 Mar 2015 17:45:54 +0000 (18:45 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Wed, 18 Mar 2015 17:45:54 +0000 (18:45 +0100)
sonar-batch/src/main/java/org/sonar/batch/index/SourcePersister.java
sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml

index e27d9eca16858d544188af97a85f94a046e29ebd..5a86495495dd064722ccb535c1016e29fdbf8e1c 100644 (file)
@@ -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);
index 49ede1dfb3061bb6cd43784275df870a5ceffac5..061c84eb19de5e7a55cad8b9ef32fa5235d21113 100644 (file)
@@ -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>