Skip to content

Commit

Permalink
fix(): better handle of regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Skraye committed Jul 30, 2024
1 parent e5cd7d2 commit dd4cae2
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.net.URI;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
Expand Down Expand Up @@ -123,13 +124,18 @@ public UploadFiles.Output run(RunContext runContext) throws Exception {
for (Object file : filesList) {
Optional<URI> uri = FileUtils.getURI(file.toString());
// Immediately handle strings that are full URI
if (uri.isPresent()) {
if (runContext.storage().isFileExist(uri.get())) {
try {

if (uri.isPresent() && runContext.storage().isFileExist(uri.get())) {
Path targetFilePath = Path.of(renderedDestination, FileUtils.getFileName(uri.get()));
storageNamespace.putFile(targetFilePath, runContext.storage().getFile(uri.get()), conflict);
} else {
regexs.add(file.toString());
}
// else ignore
} else {
}
// If the string is not a valid URI, try to use it as a regex
catch (InvalidPathException | NullPointerException e) {
runContext.logger().debug("File {} is not a valid URI, using it as a regex", file);
regexs.add(file.toString());
}
}
Expand Down

0 comments on commit dd4cae2

Please sign in to comment.