Skip to content

Commit

Permalink
need long timeouts for large file writes
Browse files Browse the repository at this point in the history
  • Loading branch information
kmulvey committed Jan 31, 2023
1 parent ce3b26a commit 0b986fe
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/imageconvert/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func watchDir(inputPath path.Path, files chan path.WatchEvent, tr humantime.Time
func waitTilFileWritesComplete(eventsIn, eventsOut chan path.WatchEvent) {

var cache = make(map[string]TimeOfEntry)
var ticker = time.NewTicker(500 * time.Millisecond)
var ticker = time.NewTicker(200 * time.Millisecond)

for {
select {
Expand All @@ -60,11 +60,13 @@ func waitTilFileWritesComplete(eventsIn, eventsOut chan path.WatchEvent) {
close(eventsOut)
return
}

cache[event.Entry.AbsolutePath] = TimeOfEntry{Entry: event.Entry, Time: time.Now()}

case <-ticker.C:

for filename, entry := range cache {
if time.Since(entry.Time) > 200*time.Millisecond {
if time.Since(entry.Time) > 3*time.Second { // this is a long time because large files take a while to get written to spinning rust
eventsOut <- path.WatchEvent{Entry: entry.Entry, Op: 6} // 6 here is nonsense but it doesnt matter
delete(cache, filename)
}
Expand Down

0 comments on commit 0b986fe

Please sign in to comment.