diff --git a/ers/filecsv.go b/ers/filecsv.go index 4e82856c0..484c42caa 100644 --- a/ers/filecsv.go +++ b/ers/filecsv.go @@ -81,6 +81,11 @@ func (rdr *CSVFileER) Serve() (err error) { case time.Duration(0): // 0 disables the automatic read, maybe done per API return case time.Duration(-1): + + // Ensure that files already existing in the source path are processed + // before the reader starts listening for filesystem change events. + processReaderDir(rdr.sourceDir, utils.CSVSuffix, rdr.processFile) + return utils.WatchDir(rdr.sourceDir, rdr.processFile, utils.ERs, rdr.rdrExit) default: diff --git a/ers/filefwv.go b/ers/filefwv.go index c8144069b..64ce69682 100644 --- a/ers/filefwv.go +++ b/ers/filefwv.go @@ -89,6 +89,11 @@ func (rdr *FWVFileER) Serve() (err error) { case time.Duration(0): // 0 disables the automatic read, maybe done per API return case time.Duration(-1): + + // Ensure that files already existing in the source path are processed + // before the reader starts listening for filesystem change events. + processReaderDir(rdr.sourceDir, utils.FWVSuffix, rdr.processFile) + return utils.WatchDir(rdr.sourceDir, rdr.processFile, utils.ERs, rdr.rdrExit) default: diff --git a/ers/filejson.go b/ers/filejson.go index 096b44b63..21b3f2c0c 100644 --- a/ers/filejson.go +++ b/ers/filejson.go @@ -82,6 +82,11 @@ func (rdr *JSONFileER) Serve() (err error) { case time.Duration(0): // 0 disables the automatic read, maybe done per API return case time.Duration(-1): + + // Ensure that files already existing in the source path are processed + // before the reader starts listening for filesystem change events. + processReaderDir(rdr.sourceDir, utils.JSONSuffix, rdr.processFile) + return utils.WatchDir(rdr.sourceDir, rdr.processFile, utils.ERs, rdr.rdrExit) default: diff --git a/ers/filexml.go b/ers/filexml.go index 15511812a..0e541e1ce 100644 --- a/ers/filexml.go +++ b/ers/filexml.go @@ -83,6 +83,11 @@ func (rdr *XMLFileER) Serve() (err error) { case time.Duration(0): // 0 disables the automatic read, maybe done per API return case time.Duration(-1): + + // Ensure that files already existing in the source path are processed + // before the reader starts listening for filesystem change events. + processReaderDir(rdr.sourceDir, utils.XMLSuffix, rdr.processFile) + return utils.WatchDir(rdr.sourceDir, rdr.processFile, utils.ERs, rdr.rdrExit) default: