Skip to content

Commit

Permalink
Only set executable permission on staged files if required and not set (
Browse files Browse the repository at this point in the history
#1414)

When staging files, only set the target executable permission if the source file is executable and the target file is not executable.

It can be problematic if setting the executable permission on a target file multiple times if using inotify to watch staged files as inotify events will be triggered even when the permission is already set. This fix ensures the executable permission is only set once, to avoid unnecessary inotify events.

Co-authored-by: Nepomuk Seiler <muuki88@users.noreply.github.com>
  • Loading branch information
DylanArnold and muuki88 committed Jun 23, 2021
1 parent babba30 commit d1e70b4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/scala/com/typesafe/sbt/packager/Stager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ object Stager {
// TODO - Config file user-readable permissions....
for {
(from, to) <- copies
if from.canExecute
// Only set executable permission if it needs to be set. Note: calling to.setExecutable(true) if it's already
// executable is undesirable for a developer using inotify to watch this file as it will trigger events again
if from.canExecute && !to.canExecute
} to.setExecutable(true)
stageDirectory
}
Expand Down

0 comments on commit d1e70b4

Please sign in to comment.