Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create bag in place with includeHidden = true #93

Closed
rvanheest opened this issue Jun 28, 2017 · 4 comments
Closed

Create bag in place with includeHidden = true #93

rvanheest opened this issue Jun 28, 2017 · 4 comments
Labels

Comments

@rvanheest
Copy link

When I call BagCreator.bagInPlace with includeHidden = true, the call produces a java.nio.file.FileSystemException. In this case it wants to move the newly created data/ folder into itself (data/data/), which isn't possible.

An hour of debugging later I found out that this is because of the following code block:

try(final DirectoryStream<Path> directoryStream = Files.newDirectoryStream(root)){
  for(final Path path : directoryStream){
    if(!path.equals(dataDir) && !Files.isHidden(path) || includeHidden){
      Files.move(path, dataDir.resolve(path.getFileName()));
    }
  }
}

Here if(!path.equals(dataDir) && !Files.isHidden(path) || includeHidden) must actually be if(!path.equals(dataDir) && (!Files.isHidden(path) || includeHidden)) (extra parentheses around !Files.isHidden(path) || includeHidden). This has to do with operator precedence in Java: && binds stronger than ||.

In the test suite I only found a test with includeHidden = false, which works correctly. If you will duplicate that one with includeHidden = true, you will find the same error.

@rvanheest
Copy link
Author

related to bagInPlace: why doesn't it generate a bag-info.txt also?

@johnscancella
Copy link
Contributor

Thank you for reporting this issue! This is fixed in version 5.0.2.
As to why it doesn't generate a bag-info.txt is due to it being optional and there is no default values to enter into it. If other people would find this of value please up vote this comment.

@rvanheest
Copy link
Author

Thanks for the quick response. I agree bag-info is optional, but so is tagmanifest. Maybe a basic bag-info with Payload-Oxum and bagging date would be a good start? That's what we had in version 4 of this library, if I remember correctly.

johnscancella added a commit that referenced this issue Jun 29, 2017
…in place, and defaults to include date bagged and payload-oxum
@rvanheest
Copy link
Author

This latest commit looks great! Most of the stuff you added was added by me manually by setting the metadata elements manually and doing another BagWriter.write after the BagCreator.bagInPlace. This is way better, though! Would be happy to see the release soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants