diff --git a/ers/filecsv.go b/ers/filecsv.go index 4098e6273..6b7fcf986 100644 --- a/ers/filecsv.go +++ b/ers/filecsv.go @@ -97,6 +97,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 27cb2a281..c58e1ddcd 100644 --- a/ers/filefwv.go +++ b/ers/filefwv.go @@ -106,6 +106,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 d81bbf548..fed968c88 100644 --- a/ers/filejson.go +++ b/ers/filejson.go @@ -100,6 +100,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.JSNSuffix, 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 9c7514a52..df3e4ea97 100644 --- a/ers/filexml.go +++ b/ers/filexml.go @@ -82,6 +82,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: