Skip to content

Commit

Permalink
refs #101 - make sure we test using the dos property for a file being…
Browse files Browse the repository at this point in the history
… hidden on windows
  • Loading branch information
johnscancella committed Jan 16, 2018
1 parent 75cec6e commit b7c3f0c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
Expand Down Expand Up @@ -49,7 +48,7 @@ public FileVisitResult abstractPreVisitDirectory(final Path dir, final String di

@Override
public FileVisitResult visitFile(final Path path, final BasicFileAttributes attrs)throws IOException{
if(!includeHiddenFiles && Files.isHidden(path) && !path.endsWith(".keep")){
if(!includeHiddenFiles && PathUtils.isHidden(path) && !path.endsWith(".keep")){
logger.debug(messages.getString("skipping_hidden_file"), path);
}
else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private static void moveDataFilesIfNeeded(final Bag bag, final boolean includeHi
final Path dataDir = PathUtils.getDataDir(bag);
try(final DirectoryStream<Path> directoryStream = Files.newDirectoryStream(bag.getRootDir())){
for(final Path path : directoryStream){
if(!path.equals(dataDir) && (!Files.isHidden(path) || includeHidden)){
if(!path.equals(dataDir) && (!PathUtils.isHidden(path) || includeHidden)){
Files.move(path, dataDir.resolve(path.getFileName()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
Expand All @@ -12,6 +11,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import gov.loc.repository.bagit.util.PathUtils;

/**
* Implements {@link SimpleFileVisitor} to ensure that the encountered file is in one of the manifests.
*/
Expand All @@ -26,7 +27,7 @@ public AbstractPayloadFileExistsInManifestsVistor(final boolean ignoreHiddenFile

@Override
public FileVisitResult preVisitDirectory(final Path dir, final BasicFileAttributes attrs) throws IOException {
if(ignoreHiddenFiles && Files.isHidden(dir) || dir.endsWith(Paths.get(".bagit"))){
if(ignoreHiddenFiles && PathUtils.isHidden(dir) || dir.endsWith(Paths.get(".bagit"))){
logger.debug(messages.getString("skipping_hidden_file"), dir);
return FileVisitResult.SKIP_SUBTREE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public void testBagInPlace() throws IOException, NoSuchAlgorithmException{
File bagitFile = new File(folder.getRoot(), "bagit.txt");
assertTrue(bagitFile.exists());

//make sure the hidden folder was not included in the data directory
File hiddenFolder = new File(bag.getRootDir().resolve("data").toFile(), ".hiddenFolder");
assertFalse(hiddenFolder.exists());

for(Manifest manifest : bag.getPayLoadManifests()){
for(Path expectedPayloadFile : manifest.getFileToChecksumMap().keySet()){
assertTrue(structure.regularPayloadFiles.contains(expectedPayloadFile));
Expand Down

0 comments on commit b7c3f0c

Please sign in to comment.