File tree Expand file tree Collapse file tree 2 files changed +6
-10
lines changed
Expand file tree Collapse file tree 2 files changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ package file
88import (
99 "context"
1010 "errors"
11- "fmt"
1211 "log/slog"
1312 "os"
1413 "path/filepath"
@@ -148,6 +147,12 @@ func (fws *FileWatcherService) addWatchers(ctx context.Context) {
148147func (fws * FileWatcherService ) removeWatchers (ctx context.Context ) {
149148 for _ , directoryBeingWatched := range fws .watcher .WatchList () {
150149 if _ , err := os .Stat (directoryBeingWatched ); errors .Is (err , os .ErrNotExist ) {
150+ slog .DebugContext (
151+ ctx ,
152+ "Directory does not exist removing watcher" ,
153+ "directory" , directoryBeingWatched ,
154+ )
155+
151156 fws .removeWatcher (ctx , directoryBeingWatched )
152157 fws .filesChanged .Store (true )
153158 } else if _ , ok := fws .directoriesToWatch [directoryBeingWatched ]; ! ok {
@@ -158,7 +163,6 @@ func (fws *FileWatcherService) removeWatchers(ctx context.Context) {
158163}
159164
160165func (fws * FileWatcherService ) handleEvent (ctx context.Context , event fsnotify.Event ) {
161- fmt .Println (event )
162166 if fws .enabled .Load () {
163167 if fws .isEventSkippable (event ) {
164168 return
Original file line number Diff line number Diff line change @@ -273,16 +273,9 @@ func TestFileWatcherService_Watch(t *testing.T) {
273273 })
274274
275275 t .Run ("Test 3: Directory deleted" , func (t * testing.T ) {
276- fileDeleteError := os .Remove (file .Name ())
277- require .NoError (t , fileDeleteError )
278- t .Logf ("Removing directory %s" , testDirectory )
279276 dirDeleteError := os .RemoveAll (testDirectory )
280277 require .NoError (t , dirDeleteError )
281278
282- if _ , err := os .Stat (testDirectory ); ! os .IsNotExist (err ) {
283- t .Fatalf ("Expected directory to not exist" )
284- }
285-
286279 // Check that directory is no longer being watched
287280 assert .Eventually (t , func () bool {
288281 _ , ok := fileWatcherService .directoriesToWatch [testDirectory ]
@@ -291,7 +284,6 @@ func TestFileWatcherService_Watch(t *testing.T) {
291284
292285 assert .Eventually (t , func () bool {
293286 directoriesBeingWatched := fileWatcherService .watcher .WatchList ()
294- t .Log (directoriesBeingWatched )
295287 return len (directoriesBeingWatched ) == 0
296288 }, 1 * time .Second , 100 * time .Millisecond )
297289 })
You can’t perform that action at this time.
0 commit comments