Skip to content

Commit

Permalink
Use custom field for filename instead of exception message in Produce…
Browse files Browse the repository at this point in the history
…rFileNotFoundException
  • Loading branch information
marwiik committed Jan 5, 2025
1 parent 7983617 commit 8493601
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/vafer/jdeb/DataBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ private void createParentDirectories( String filename, String user, long uid, St
data.produce(receiver);
}
} catch (ProducerFileNotFoundException e) {
// Get the offending file name from the exception message to check
// Get the offending file name from the exception to check
// if it's a symlink.
if (Files.isSymbolicLink(Paths.get(e.getMessage())) && ignoreBrokenLinks) {
if (Files.isSymbolicLink(Paths.get(e.getFilePath())) && ignoreBrokenLinks) {
console.info("Ignoring broken symlink " + e.getMessage());
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

public class ProducerFileNotFoundException extends FileNotFoundException {

private String filePath;

public ProducerFileNotFoundException() {
super();
Expand All @@ -17,4 +18,12 @@ public ProducerFileNotFoundException(String message, Throwable cause) {
super(message);
this.initCause(cause);
}

public void setFilePath(String path) {
this.filePath = path;
}

public String getFilePath() {
return this.filePath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public void produceFile( final DataConsumer consumer,
Producers.produceInputStreamWithEntry(consumer, new FileInputStream(file), fileEntry);
}
catch (FileNotFoundException e) {
ProducerFileNotFoundException pe = new ProducerFileNotFoundException(file.getAbsolutePath(), e);
ProducerFileNotFoundException pe = new ProducerFileNotFoundException(e.getMessage(), e);
pe.setFilePath(file.getAbsolutePath());
throw pe;
}
}
Expand Down

0 comments on commit 8493601

Please sign in to comment.