Update behaviour of file readers using inotify

Ensure that files already existing in the source path are processed
before the reader starts listening for filesystem change events.
This commit is contained in:
ionutboangiu
2024-04-03 18:10:10 +03:00
committed by Dan Christian Bogos
parent a362511d7a
commit 5c1e128f4f
4 changed files with 20 additions and 0 deletions

View File

@@ -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:

View File

@@ -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:

View File

@@ -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:

View File

@@ -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: