File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -591,13 +591,17 @@ func (s *Runner) monitorGitDir(ctx context.Context, dir string) <-chan string {
591
591
}
592
592
593
593
func (s * Runner ) monitorWorkDirScanner (ctx context.Context ) <- chan string {
594
+ type memoFile struct {
595
+ time time.Time
596
+ size int64
597
+ }
594
598
triggereds := make (chan string , 1 )
595
599
triggereds <- ""
596
600
go func () {
597
601
defer close (triggereds )
598
602
t := time .NewTicker (50 * time .Millisecond )
599
603
defer t .Stop ()
600
- memo := make (map [string ]time. Time )
604
+ memo := make (map [string ]memoFile )
601
605
for {
602
606
select {
603
607
case <- ctx .Done ():
@@ -624,15 +628,23 @@ func (s *Runner) monitorWorkDirScanner(ctx context.Context) <-chan string {
624
628
continue
625
629
}
626
630
mtime := info .ModTime ()
627
- memoMTime , ok := memo [path ]
631
+ fsize := info .Size ()
632
+ mf , ok := memo [path ]
628
633
if ! ok {
629
- memo [path ] = mtime
630
- memoMTime = mtime
634
+ memo [path ] = memoFile {
635
+ time : mtime ,
636
+ size : fsize ,
637
+ }
638
+ mf = memo [path ]
631
639
}
632
- if mtime .Equal (memoMTime ) {
640
+ if mtime .Equal (mf . time ) && fsize == mf . size {
633
641
continue
634
642
}
635
- memo [path ] = mtime
643
+ fmt .Println (">>>> file changed:" , path )
644
+ memo [path ] = memoFile {
645
+ time : mtime ,
646
+ size : fsize ,
647
+ }
636
648
triggereds <- path
637
649
}
638
650
return nil
You can’t perform that action at this time.
0 commit comments