Skip to content

Commit e7e76da

Browse files
committed
refs #99 - don't try to make the path relative for fetch files
1 parent b7c3f0c commit e7e76da

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/main/java/gov/loc/repository/bagit/writer/BagWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static void write(final Bag bag, final Path outputDir) throws IOException
6161
}
6262
if(bag.getItemsToFetch().size() > 0){
6363
logger.debug(messages.getString("writing_fetch_file"));
64-
FetchWriter.writeFetchFile(bag.getItemsToFetch(), bagitDir, bag.getRootDir(), bag.getFileEncoding());
64+
FetchWriter.writeFetchFile(bag.getItemsToFetch(), bagitDir, bag.getFileEncoding());
6565
}
6666
if(bag.getTagManifests().size() > 0){
6767
logger.debug(messages.getString("writing_tag_manifests"));

src/main/java/gov/loc/repository/bagit/writer/FetchWriter.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,22 @@ private FetchWriter(){
2929
*
3030
* @param itemsToFetch the list of {@link FetchItem}s to write into the fetch.txt
3131
* @param outputDir the root of the bag
32-
* @param bagitRootDir the path to the root of the bag
3332
* @param charsetName the name of the encoding for the file
3433
*
3534
* @throws IOException if there was a problem writing a file
3635
*/
37-
public static void writeFetchFile(final List<FetchItem> itemsToFetch, final Path outputDir, final Path bagitRootDir, final Charset charsetName) throws IOException{
36+
public static void writeFetchFile(final List<FetchItem> itemsToFetch, final Path outputDir, final Charset charsetName) throws IOException{
3837
logger.debug(messages.getString("writing_fetch_file_to_path"), outputDir);
3938
final Path fetchFilePath = outputDir.resolve("fetch.txt");
4039

4140
for(final FetchItem item : itemsToFetch){
42-
final String line = formatFetchLine(item, bagitRootDir);
41+
final String line = formatFetchLine(item);
4342
logger.debug(messages.getString("writing_line_to_file"), line, fetchFilePath);
4443
Files.write(fetchFilePath, line.getBytes(charsetName), StandardOpenOption.APPEND, StandardOpenOption.CREATE);
4544
}
4645
}
4746

48-
private static String formatFetchLine(final FetchItem fetchItem, final Path bagitRootDir){
47+
private static String formatFetchLine(final FetchItem fetchItem){
4948
final StringBuilder sb = new StringBuilder();
5049
sb.append(fetchItem.getUrl()).append(' ');
5150

@@ -56,7 +55,7 @@ private static String formatFetchLine(final FetchItem fetchItem, final Path bagi
5655
sb.append(fetchItem.getLength()).append(' ');
5756
}
5857

59-
sb.append(RelativePathWriter.formatRelativePathString(bagitRootDir, fetchItem.getPath()));
58+
sb.append(fetchItem.getPath());
6059

6160
return sb.toString();
6261
}

src/test/java/gov/loc/repository/bagit/writer/FetchWriterTest.java

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

3838

3939
assertFalse(fetch.exists());
40-
FetchWriter.writeFetchFile(itemsToFetch, Paths.get(rootDir.toURI()), rootPath, StandardCharsets.UTF_8);
40+
FetchWriter.writeFetchFile(itemsToFetch, Paths.get(rootDir.toURI()), StandardCharsets.UTF_8);
4141
assertTrue(fetch.exists());
4242
}
4343
}

0 commit comments

Comments
 (0)