Adjustments
This commit is contained in:
parent
422971a914
commit
ac4f79ff7a
@ -51,6 +51,7 @@ class InputDirectoryWatcher(@Autowired var coordinator: Coordinator): FileWatche
|
|||||||
val watchDirectories = SharedConfig.incomingContent
|
val watchDirectories = SharedConfig.incomingContent
|
||||||
val queue = FileWatcherQueue()
|
val queue = FileWatcherQueue()
|
||||||
|
|
||||||
|
@Volatile
|
||||||
private var isStopping: Boolean = false
|
private var isStopping: Boolean = false
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
fun setStop() {
|
fun setStop() {
|
||||||
@ -86,28 +87,35 @@ class InputDirectoryWatcher(@Autowired var coordinator: Coordinator): FileWatche
|
|||||||
private suspend fun startWatchOnDirectory(file: File) {
|
private suspend fun startWatchOnDirectory(file: File) {
|
||||||
if (activeWatchers.any {it -> it.file.absolutePath == file.absolutePath}) {
|
if (activeWatchers.any {it -> it.file.absolutePath == file.absolutePath}) {
|
||||||
log.error { "Attempting to start a watcher on an already watched directory ${file.absolutePath}" }
|
log.error { "Attempting to start a watcher on an already watched directory ${file.absolutePath}" }
|
||||||
|
return
|
||||||
}
|
}
|
||||||
val watcher = file.asWatcher { watcher ->
|
val watcher = file.asWatcher { watcher ->
|
||||||
watcher.consumeEach {
|
try {
|
||||||
if (it.file == SharedConfig.incomingContent) {
|
watcher.consumeEach {
|
||||||
logger.info { "IO Watcher ${it.kind} on ${it.file.absolutePath}" }
|
if (it.file == SharedConfig.incomingContent) {
|
||||||
} else {
|
logger.info { "IO Watcher ${it.kind} on ${it.file.absolutePath}" }
|
||||||
logger.info { "IO Event: ${it.kind}: ${it.file.name}" }
|
} else {
|
||||||
}
|
logger.info { "IO Event: ${it.kind}: ${it.file.name}" }
|
||||||
try {
|
}
|
||||||
when (it.kind) {
|
try {
|
||||||
Deleted -> removeFile(it.file)
|
when (it.kind) {
|
||||||
Initialized -> { /* Do nothing */ }
|
Deleted -> removeFile(it.file)
|
||||||
else -> {
|
Initialized -> { /* Do nothing */ }
|
||||||
val added = addFile(it.file)
|
else -> {
|
||||||
if (!added) {
|
val added = addFile(it.file)
|
||||||
logger.info { "Ignoring event kind: ${it.kind.name} for file ${it.file.name} as it is not a supported video file" }
|
if (!added) {
|
||||||
|
logger.info { "Ignoring event kind: ${it.kind.name} for file ${it.file.name} as it is not a supported video file" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
log.error { "Consume failed ${e.message}" }
|
||||||
|
e.printStackTrace()
|
||||||
|
watcher.close()
|
||||||
}
|
}
|
||||||
}.also { watcher ->
|
}.also { watcher ->
|
||||||
watcher.watcher.invokeOnClose {
|
watcher.watcher.invokeOnClose {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user