Skip to content

Commit 845bf23

Browse files
committed
refs #48 - fetch items should be resolved relative to base directory instead of to data directory
1 parent 16a6d3b commit 845bf23

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/main/java/gov/loc/repository/bagit/verify/BagVerifier.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public void isComplete(Bag bag, boolean ignoreHiddenFiles) throws
205205

206206
Path dataDir = getDataDir(bag);
207207

208-
checkFetchItemsExist(bag.getItemsToFetch(), dataDir);
208+
checkFetchItemsExist(bag.getItemsToFetch(), bag.getRootDir());
209209

210210
checkBagitFileExists(bag.getRootDir(), bag.getVersion());
211211

@@ -226,10 +226,10 @@ protected Path getDataDir(Bag bag){
226226
return bag.getRootDir().resolve(PAYLOAD_DIR_NAME);
227227
}
228228

229-
protected void checkFetchItemsExist(List<FetchItem> items, Path dataDir) throws FileNotInPayloadDirectoryException{
230-
logger.info("Checking if all [{}] items in fetch.txt exist in the [{}]", items.size(), dataDir);
229+
protected void checkFetchItemsExist(List<FetchItem> items, Path bagDir) throws FileNotInPayloadDirectoryException{
230+
logger.info("Checking if all [{}] items in fetch.txt exist in the [{}]", items.size(), bagDir);
231231
for(FetchItem item : items){
232-
Path file = dataDir.resolve(item.path);
232+
Path file = bagDir.resolve(item.path);
233233
if(!Files.exists(file)){
234234
throw new FileNotInPayloadDirectoryException("Fetch item " + item + " has not been fetched!");
235235
}

src/test/java/gov/loc/repository/bagit/verify/BagVerifierTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public void testIsComplete() throws Exception{
131131

132132
@Test(expected=FileNotInPayloadDirectoryException.class)
133133
public void testErrorWhenFetchItemsDontExist() throws Exception{
134-
rootDir = Paths.get(getClass().getClassLoader().getResource("bags/v0_96/holey-bag").toURI());
134+
rootDir = Paths.get(getClass().getClassLoader().getResource("bad-fetch-bag").toURI());
135135
Bag bag = reader.read(rootDir);
136136

137137
sut.isComplete(bag, true);

0 commit comments

Comments
 (0)