From 4846a74320ccc44b00df997d6a80f15aaf99f5f8 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Thu, 7 Jun 2018 22:19:55 +0300 Subject: [PATCH] reload modified directories when loading cache Related #92 --- nav.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/nav.go b/nav.go index 701764c..c3b507d 100644 --- a/nav.go +++ b/nav.go @@ -214,7 +214,21 @@ func (nav *nav) loadDir(path string) *dir { return d } - if d.sortType != gOpts.sortType { + s, err := os.Stat(d.path) + if err != nil { + return d + } + + switch { + case s.ModTime().After(d.loadTime): + go func() { + d.loadTime = time.Now() + nd := newDir(path) + nd.sort() + nd.find(d.name(), nav.height) + nav.dirChan <- nd + }() + case d.sortType != gOpts.sortType: go func() { d.loading = true name := d.name()