Skip to content

Commit ad6c0d9

Browse files
committed
Remove file watcher code
Now that we refresh upon focus, we can scrap this file watching code. Stefan says few git UIs use file watching, and I understand why: the reason this code was problematic in the first place is that watching files is expensive and if you have too many open file handles that can cause problems. Importantly: this code that's being removed was _already_ dead.
1 parent c8520fb commit ad6c0d9

File tree

22 files changed

+0
-2450
lines changed

22 files changed

+0
-2450
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ require (
99
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21
1010
github.com/creack/pty v1.1.11
1111
github.com/fsmiamoto/git-todo-parser v0.0.5
12-
github.com/fsnotify/fsnotify v1.4.7
1312
github.com/gdamore/tcell/v2 v2.6.0
1413
github.com/go-errors/errors v1.4.2
1514
github.com/gookit/color v1.4.2

go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL
8282
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
8383
github.com/fsmiamoto/git-todo-parser v0.0.5 h1:Bhzd/vz/6Qm3udfkd6NO9fWfD3TpwR9ucp3N75/J5I8=
8484
github.com/fsmiamoto/git-todo-parser v0.0.5/go.mod h1:B+AgTbNE2BARvJqzXygThzqxLIaEWvwr2sxKYYb0Fas=
85-
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
8685
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
8786
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
8887
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=

pkg/gui/controllers.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ func (gui *Gui) resetHelpersAndControllers() {
5656
stagingHelper,
5757
mergeConflictsHelper,
5858
worktreeHelper,
59-
gui.fileWatcher,
6059
)
6160
diffHelper := helpers.NewDiffHelper(helperCommon)
6261
cherryPickHelper := helpers.NewCherryPickHelper(

pkg/gui/controllers/helpers/refresh_helper.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ type RefreshHelper struct {
2828
stagingHelper *StagingHelper
2929
mergeConflictsHelper *MergeConflictsHelper
3030
worktreeHelper *WorktreeHelper
31-
fileWatcher types.IFileWatcher
3231
}
3332

3433
func NewRefreshHelper(
@@ -39,7 +38,6 @@ func NewRefreshHelper(
3938
stagingHelper *StagingHelper,
4039
mergeConflictsHelper *MergeConflictsHelper,
4140
worktreeHelper *WorktreeHelper,
42-
fileWatcher types.IFileWatcher,
4341
) *RefreshHelper {
4442
return &RefreshHelper{
4543
c: c,
@@ -49,7 +47,6 @@ func NewRefreshHelper(
4947
stagingHelper: stagingHelper,
5048
mergeConflictsHelper: mergeConflictsHelper,
5149
worktreeHelper: worktreeHelper,
52-
fileWatcher: fileWatcher,
5350
}
5451
}
5552

@@ -548,10 +545,6 @@ func (self *RefreshHelper) refreshStateFiles() error {
548545
fileTreeViewModel.SetTree()
549546
fileTreeViewModel.RWMutex.Unlock()
550547

551-
if err := self.fileWatcher.AddFilesToFileWatcher(files); err != nil {
552-
return err
553-
}
554-
555548
return nil
556549
}
557550

pkg/gui/file_watching.go

Lines changed: 0 additions & 137 deletions
This file was deleted.

pkg/gui/gui.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ type Gui struct {
7272
Updater *updates.Updater
7373
statusManager *status.StatusManager
7474
waitForIntro sync.WaitGroup
75-
fileWatcher *fileWatcher
7675
viewBufferManagerMap map[string]*tasks.ViewBufferManager
7776
// holds a mapping of view names to ptmx's. This is for rendering command outputs
7877
// from within a pty. The point of keeping track of them is so that if we re-size
@@ -476,8 +475,6 @@ func NewGui(
476475
afterLayoutFuncs: make(chan func() error, 1000),
477476
}
478477

479-
gui.WatchFilesForChanges()
480-
481478
gui.PopupHandler = popup.NewPopupHandler(
482479
cmn,
483480
func(ctx goContext.Context, opts types.CreatePopupPanelOpts) error {
@@ -680,10 +677,6 @@ func (gui *Gui) RunAndHandleError(startArgs appTypes.StartArgs) error {
680677
manager.Close()
681678
}
682679

683-
if !gui.fileWatcher.Disabled {
684-
gui.fileWatcher.Watcher.Close()
685-
}
686-
687680
close(gui.stopChan)
688681

689682
switch err {

pkg/gui/types/common.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,6 @@ const (
282282
COMPLETE
283283
)
284284

285-
type IFileWatcher interface {
286-
AddFilesToFileWatcher(files []*models.File) error
287-
}
288-
289285
// screen sizing determines how much space your selected window takes up (window
290286
// as in panel, not your terminal's window). Sometimes you want a bit more space
291287
// to see the contents of a panel, and this keeps track of how much maximisation

vendor/github.com/fsnotify/fsnotify/.gitignore

Lines changed: 0 additions & 6 deletions
This file was deleted.

vendor/github.com/fsnotify/fsnotify/AUTHORS

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)