Skip to content

Commit

Permalink
Do not use temporary folder for db recreation files
Browse files Browse the repository at this point in the history
  • Loading branch information
theotherp committed Dec 3, 2024
1 parent d25d018 commit d16e56a
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.commons.lang3.RandomStringUtils;
import org.flywaydb.core.Flyway;
import org.nzbhydra.NzbHydra;
import org.nzbhydra.springnative.ReflectionMarker;
Expand Down Expand Up @@ -133,6 +134,7 @@ private static void migrateToH2v2IfNeeded(File databaseFile, String dbConnection
try {
// TODO sist 02.12.2024: Build for linux and arm and upload all as assets
// TODO sist 02.12.2024: Build and upload arm release
// TODO sist 03.12.2024: Delete all dbrecreation* files
logger.debug("org.graalvm.nativeimage.imagecode: {}", System.getProperty("org.graalvm.nativeimage.imagecode"));
boolean useDbTool = System.getProperty("org.graalvm.nativeimage.imagecode") != null;
if ("false".equals(System.getenv("use_db_tool"))) {
Expand Down Expand Up @@ -245,7 +247,9 @@ private static void runDbTool(List<String> commandParameters, String errorMessag
private static File downloadFile(String url, String suffix) throws IOException {
//Can't use Hydra request factory as no config was loaded
final ClientHttpRequest request = simpleClientHttpRequestFactory.createRequest(URI.create(url), HttpMethod.GET);
final File file = Files.createTempFile("nzbhydra", suffix).toFile();

//Do not use a temporary folder because we may not have writing or execution rights there but we should have them inside our own folder
final File file = new File("dbrecreation-" + RandomStringUtils.insecure().nextAlphabetic(5) + suffix);
file.delete();
logger.debug("Downloading file from {} to {}. Will be deleted on exit", url, file);
try (ClientHttpResponse response = request.execute()) {
Expand Down

0 comments on commit d16e56a

Please sign in to comment.