Skip to content

Commit

Permalink
revert(mpconfig): by request from @pdudits, this isn't necessary for …
Browse files Browse the repository at this point in the history
…now.

This reverts commit 401555d.
  • Loading branch information
poikilotherm committed Jan 27, 2021
1 parent 401555d commit ce30d87
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@
import java.nio.file.WatchService;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;

Expand Down Expand Up @@ -206,7 +210,6 @@ public final void run() {
}

private static final Logger logger = Logger.getLogger(DirConfigSource.class.getName());
static final String[] ignoredExtensions = {".xml", ".yaml", ".yml", ".json", ".properties"};
private Path directory;
private final ConcurrentHashMap<String, DirProperty> properties = new ConcurrentHashMap<>();

Expand Down Expand Up @@ -401,7 +404,6 @@ public final static boolean isAptFile(Path path, BasicFileAttributes atts) throw
return path != null && Files.exists(path) &&
Files.isRegularFile(path) && Files.isReadable(path) &&
!path.getFileName().toString().startsWith(".") &&
Arrays.stream(ignoredExtensions).noneMatch(ext -> path.getFileName().toString().endsWith(ext)) &&
atts.size() < 512*1024;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.*;

public class DirConfigSourceTest {

Expand Down Expand Up @@ -150,30 +149,25 @@ public void testIsAptDir() throws IOException {

@Test
public void testIsAptFile() throws IOException {

Map<Path, Boolean> examples = new HashMap<>();
examples.put(subpath( "aptdir", "aptfile"), TRUE);
examples.put(subpath( "aptdir", ".unaptfile"), FALSE);

assertFalse(DirConfigSource.isAptFile(null, null));
assertFalse(DirConfigSource.isAptFile(subpath( "aptdir", "aptnotexisting"), null));
assertEquals(FALSE, DirConfigSource.isAptFile(null, null));
assertEquals(FALSE, DirConfigSource.isAptFile(subpath( "aptdir", "aptnotexisting"), null));
for (Map.Entry<Path, Boolean> ex : examples.entrySet()) {
BasicFileAttributes atts = writeFile(ex.getKey(), "test");
assertEquals(ex.getValue(), DirConfigSource.isAptFile(ex.getKey(), atts));
}

Path file100k = subpath("aptdir", "100k-file");
BasicFileAttributes atts100k = writeRandFile(file100k, 100*1024);
assertTrue(DirConfigSource.isAptFile(file100k, atts100k));
assertEquals(TRUE, DirConfigSource.isAptFile(file100k, atts100k));

Path file600k = subpath("aptdir", "600k-file");
BasicFileAttributes atts600k = writeRandFile(file600k, 600*1024);
assertFalse(DirConfigSource.isAptFile(file600k, atts600k));

for (String ext : DirConfigSource.ignoredExtensions) {
Path file = subpath("aptdir", "ignorefile"+ext);
BasicFileAttributes attsFile = writeFile(file, "test");
assertFalse(DirConfigSource.isAptFile(file, attsFile));
}
assertEquals(FALSE, DirConfigSource.isAptFile(file600k, atts600k));
}

@Test
Expand Down

0 comments on commit ce30d87

Please sign in to comment.