Skip to content

Commit

Permalink
only check bind mount conflict if sync action is involved
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Dec 19, 2024
1 parent 56e92e3 commit 8f644ee
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/compose/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ func (s *composeService) watch(ctx context.Context, syncChannel chan bool, proje

var paths, pathLogs []string
for _, trigger := range config.Watch {
if trigger.Action != types.WatchActionRebuild && checkIfPathAlreadyBindMounted(trigger.Path, service.Volumes) {
if isSync(trigger) && checkIfPathAlreadyBindMounted(trigger.Path, service.Volumes) {
logrus.Warnf("path '%s' also declared by a bind mount volume, this path won't be monitored!\n", trigger.Path)
continue
} else {
var initialSync bool
success, err := trigger.Extensions.Get("x-initialSync", &initialSync)
if err == nil && success && initialSync && (trigger.Action == types.WatchActionSync || trigger.Action == types.WatchActionSyncRestart) {
if err == nil && success && initialSync && isSync(trigger) {
// Need to check initial files are in container that are meant to be synched from watch action
err := s.initialSync(ctx, project, service, trigger, ignore, syncer)
if err != nil {
Expand Down Expand Up @@ -204,6 +204,10 @@ func (s *composeService) watch(ctx context.Context, syncChannel chan bool, proje
}
}

func isSync(trigger types.Trigger) bool {
return trigger.Action == types.WatchActionSync || trigger.Action == types.WatchActionSyncRestart
}

func (s *composeService) watchEvents(ctx context.Context, project *types.Project, name string, options api.WatchOptions, watcher watch.Notify, syncer sync.Syncer, triggers []types.Trigger) error {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
Expand Down

0 comments on commit 8f644ee

Please sign in to comment.