Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit a675d5e

Browse files
committed
Create watch before initial sync
Resolves #7
1 parent 4e31fe9 commit a675d5e

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

internal/sync/sync.go

+10-8
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,17 @@ const (
222222
// Use this command to debug what wasn't sync'd correctly:
223223
// rsync -e "coder sh" -nicr ~/Projects/cdr/coder-cli/. ammar:/home/coder/coder-cli/
224224
func (s Sync) Run() error {
225+
events := make(chan notify.EventInfo, maxInflightInotify)
226+
// Set up a recursive watch.
227+
// We do this before the initial sync so we can capture any changes that may have happened during sync.
228+
err := notify.Watch(path.Join(s.LocalDir, "..."), events, notify.All)
229+
if err != nil {
230+
return xerrors.Errorf("create watch: %w", err)
231+
}
232+
defer notify.Stop(events)
233+
225234
setConsoleTitle("⏳ syncing project")
226-
err := s.initSync()
235+
err = s.initSync()
227236
if err != nil {
228237
return err
229238
}
@@ -232,13 +241,6 @@ func (s Sync) Run() error {
232241
return nil
233242
}
234243

235-
events := make(chan notify.EventInfo, maxInflightInotify)
236-
// Set up a recursive watch.
237-
err = notify.Watch(path.Join(s.LocalDir, "..."), events, notify.All)
238-
if err != nil {
239-
return xerrors.Errorf("create watch: %w", err)
240-
}
241-
defer notify.Stop(events)
242244

243245
flog.Info("watching %s for changes", s.LocalDir)
244246

0 commit comments

Comments
 (0)