Updated file watcher
This commit is contained in:
parent
614e2111f1
commit
ea281c9e3f
@ -41,7 +41,14 @@ class FileWatcher: FileWatcherEvents {
|
||||
}
|
||||
|
||||
KWatchEvent.Kind.Created, KWatchEvent.Kind.Initialized -> {
|
||||
if (validVideoFiles().contains(it.file.extension)) {
|
||||
queue.addToQueue(it.file, this@FileWatcher::onFilePending, this@FileWatcher::onFileAvailable)
|
||||
} else if (it.file.isFile) {
|
||||
logger.warn { "${it.file.name} is not a valid file type" }
|
||||
} else if (it.file.isDirectory) {
|
||||
val valid = it.file.walkTopDown().filter { f -> f.isFile && f.extension in validVideoFiles() }
|
||||
logger.warn { "${it.file.name} ignoring directory" }
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
@ -69,6 +76,15 @@ class FileWatcher: FileWatcherEvents {
|
||||
}
|
||||
}
|
||||
|
||||
fun validVideoFiles(): List<String> = listOf(
|
||||
"mkv",
|
||||
"avi",
|
||||
"mp4",
|
||||
"wmv",
|
||||
"webm",
|
||||
"mov"
|
||||
)
|
||||
|
||||
|
||||
override fun onFileAvailable(file: PendingFile) {
|
||||
logger.debug { "onFileAvailable har mottatt pendingFile ${file.file.name}" }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user