Fix temp dirs creation (#2209)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-01-21 11:38:48 +02:00
committed by GitHub
parent 567e8b38f1
commit fe518fc4fa
2 changed files with 8 additions and 4 deletions

View File

@@ -119,7 +119,12 @@ public abstract class AbstractArtifactRepository implements ArtifactRepository {
} }
// try, if not supported - ok // try, if not supported - ok
if (!file.setExecutable(false)) { if (!file.setExecutable(false)) {
log.debug("Can't set executable permissions for temp file {}", file); log.debug("Can't remove executable permissions for temp file {}", file);
}
if (directory) {
if (!file.setExecutable(true, true)) {
log.debug("Can't set executable permissions for temp directory {} for the owner", file);
}
} }
return file; return file;
} catch (final IOException e) { } catch (final IOException e) {

View File

@@ -487,8 +487,7 @@ public abstract class AbstractIntegrationTest {
try { try {
final File file = Files.createTempFile(String.valueOf(System.currentTimeMillis()), "hawkbit_test").toFile(); final File file = Files.createTempFile(String.valueOf(System.currentTimeMillis()), "hawkbit_test").toFile();
file.deleteOnExit(); file.deleteOnExit();
if (!file.setReadable(true, true) || if (!file.setReadable(true, true) || !file.setWritable(true, true)) {
!file.setWritable(true, true)) {
if (file.delete()) { // try to delete immediately, if failed - on exit if (file.delete()) { // try to delete immediately, if failed - on exit
throw new IOException("Can't set proper permissions!"); throw new IOException("Can't set proper permissions!");
} else { } else {
@@ -497,7 +496,7 @@ public abstract class AbstractIntegrationTest {
} }
// try, if not supported - ok // try, if not supported - ok
if (!file.setExecutable(false)) { if (!file.setExecutable(false)) {
log.debug("Can't set executable permissions for temp file {}", file); log.debug("Can't remove executable permissions for temp file {}", file);
} }
return file; return file;
} catch (final IOException e) { } catch (final IOException e) {