This repository was archived by the owner on Aug 30, 2024. It is now read-only.
File tree 2 files changed +12
-13
lines changed
2 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -35,34 +35,33 @@ func (cache eventCache) Add(ev timedEvent) {
35
35
cache [ev .Path ()] = ev
36
36
}
37
37
38
- // DirectoryEvents returns the list of events that pertain to directories.
39
- // The set of returns events is disjoint with FileEvents .
40
- func (cache eventCache ) DirectoryEvents () []timedEvent {
38
+ // SequentialEvents returns the list of events that pertain to directories.
39
+ // The set of returned events is disjoint with ConcurrentEvents .
40
+ func (cache eventCache ) SequentialEvents () []timedEvent {
41
41
var r []timedEvent
42
42
for _ , ev := range cache {
43
43
info , err := os .Stat (ev .Path ())
44
- if err != nil {
45
- continue
46
- }
47
- if ! info .IsDir () {
44
+ if err == nil && ! info .IsDir () {
48
45
continue
49
46
}
47
+ // Include files that have deleted here.
48
+ // It's unclear whether they're files or folders.
50
49
r = append (r , ev )
51
50
52
51
}
53
52
return r
54
53
}
55
54
56
- // FileEvents returns the list of events that pertain to files .
57
- // The set of returns events is disjoint with DirectoryEvents .
58
- func (cache eventCache ) FileEvents () []timedEvent {
55
+ // ConcurrentEvents returns the list of events that are safe to process after SequentialEvents .
56
+ // The set of returns events is disjoint with SequentialEvents .
57
+ func (cache eventCache ) ConcurrentEvents () []timedEvent {
59
58
var r []timedEvent
60
59
for _ , ev := range cache {
61
60
info , err := os .Stat (ev .Path ())
62
61
if err != nil {
63
62
continue
64
63
}
65
- if info .IsDir () {
64
+ if info .IsDir () {
66
65
continue
67
66
}
68
67
r = append (r , ev )
Original file line number Diff line number Diff line change @@ -188,12 +188,12 @@ func (s Sync) workEventGroup(evs []timedEvent) {
188
188
// and then a file is moved to it. AFAIK this dependecy only exists with Directories.
189
189
// So, we sequentially process the list of directory Renames and Creates, and then concurrently
190
190
// perform all Writes.
191
- for _ , ev := range cache .DirectoryEvents () {
191
+ for _ , ev := range cache .SequentialEvents () {
192
192
s .work (ev )
193
193
}
194
194
195
195
var wg sync.WaitGroup
196
- for _ , ev := range cache .FileEvents () {
196
+ for _ , ev := range cache .ConcurrentEvents () {
197
197
setConsoleTitle (fmtUpdateTitle (ev .Path ()))
198
198
199
199
wg .Add (1 )
You can’t perform that action at this time.
0 commit comments