Skip to content

Commit

Permalink
Fix directory checks for backup db, where container has changed perms -
Browse files Browse the repository at this point in the history
  • Loading branch information
johnaohara committed Dec 19, 2023
1 parent 6f860d8 commit 53b31e3
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.hyperfoil.tools.horreum.infra.common.ResourceLifecycleManager;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.jboss.logging.Logger;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.PostgreSQLContainer;
Expand All @@ -25,6 +26,7 @@
import static io.hyperfoil.tools.horreum.infra.common.Const.*;

public class PostgresResource implements ResourceLifecycleManager {
private static final Logger log = Logger.getLogger(PostgresResource.class);
public static final String POSTGRES_CONFIG_PROPERTIES = "postgres.config.properties";
private HorreumPostgreSQLContainer<?> postgresContainer;

Expand Down Expand Up @@ -90,8 +92,12 @@ private void checkIfDirectoryIsEmtpy(String directoryPath) {
if(!dir.isDirectory()) {
throw new RuntimeException("Directory " + directoryPath + " is not a directory!");
}
if (dir.list().length == 0) {
throw new RuntimeException("Directory " + directoryPath + " does not contain any files!");
try {
if (dir.canRead() && dir.list() == null) {
throw new RuntimeException("Directory " + directoryPath + " does not contain any files!");
}
} catch (SecurityException se){
log.warnf("Directory %s does not have correct permissions to verify!", directoryPath);
}
}

Expand Down

0 comments on commit 53b31e3

Please sign in to comment.