From d156cfffc2efd849f85bbbfc3d8f0870697ec7b1 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Fri, 4 Sep 2015 12:13:29 +0200 Subject: [PATCH] Fix project lock on windows --- .../main/java/org/sonar/batch/scan/ProjectLock.java | 13 ------------- .../sonar/batch/scan/filesystem/FileIndexer.java | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectLock.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectLock.java index f12751f9be6..8f42e7bc366 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectLock.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectLock.java @@ -31,7 +31,6 @@ import java.nio.channels.FileLock; import java.nio.channels.OverlappingFileLockException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.attribute.DosFileAttributeView; public class ProjectLock implements Startable { private static final Logger LOG = LoggerFactory.getLogger(ProjectLock.class); @@ -51,7 +50,6 @@ public class ProjectLock implements Startable { try { lockRandomAccessFile = new RandomAccessFile(lockFilePath.toFile(), "rw"); lockChannel = lockRandomAccessFile.getChannel(); - hideLockFileWindows(lockFilePath); lockFile = lockChannel.tryLock(0, 1024, false); if (lockFile == null) { @@ -65,17 +63,6 @@ public class ProjectLock implements Startable { } } - private static void hideLockFileWindows(Path p) { - try { - DosFileAttributeView fileAttrView = Files.getFileAttributeView(p, DosFileAttributeView.class); - if (fileAttrView != null) { - fileAttrView.setHidden(true); - } - } catch (IOException e) { - throw new IllegalStateException("Failed to hide file: " + p.toString(), e); - } - } - private static void failAlreadyInProgress(Exception e) { throw new IllegalStateException("Another SonarQube analysis is already in progress for this project", e); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java index da2db7cca44..6b06a999a32 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java @@ -58,7 +58,7 @@ public class FileIndexer { private static final Logger LOG = LoggerFactory.getLogger(FileIndexer.class); private static final IOFileFilter DIR_FILTER = FileFilterUtils.and(HiddenFileFilter.VISIBLE, FileFilterUtils.notFileFilter(FileFilterUtils.prefixFileFilter("."))); - private static final IOFileFilter FILE_FILTER = HiddenFileFilter.VISIBLE; + private static final IOFileFilter FILE_FILTER = FileFilterUtils.and(HiddenFileFilter.VISIBLE, FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter(".sonar_lock"))); private final List filters; private final boolean isAggregator; -- 2.39.5