Skip to content

Commit

Permalink
Fix temp dirs creation
Browse files Browse the repository at this point in the history
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
  • Loading branch information
avgustinmm committed Jan 21, 2025
1 parent e64053f commit 2569a98
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ static File createTempFile(final boolean directory) {
}
// try, if not supported - ok
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;
} catch (final IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,7 @@ private static File createTempDir() {
try {
final File file = Files.createTempFile(String.valueOf(System.currentTimeMillis()), "hawkbit_test").toFile();
file.deleteOnExit();
if (!file.setReadable(true, true) ||
!file.setWritable(true, true)) {
if (!file.setReadable(true, true) || !file.setWritable(true, true)) {
if (file.delete()) { // try to delete immediately, if failed - on exit
throw new IOException("Can't set proper permissions!");
} else {
Expand All @@ -498,7 +497,7 @@ private static File createTempDir() {
}
// try, if not supported - ok
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;
} catch (final IOException e) {
Expand Down

0 comments on commit 2569a98

Please sign in to comment.