mirror of
https://github.com/gotson/komga.git
synced 2025-01-09 04:08:00 +08:00
parent
76caa4de39
commit
d7391669f6
@ -72,14 +72,14 @@ class FileSystemScanner(
|
||||
object : FileVisitor<Path> {
|
||||
override fun preVisitDirectory(dir: Path, attrs: BasicFileAttributes): FileVisitResult {
|
||||
logger.trace { "preVisit: $dir" }
|
||||
if (dir.fileName.toString().startsWith(".") ||
|
||||
if (dir.fileName?.toString()?.startsWith(".") == true ||
|
||||
komgaProperties.librariesScanDirectoryExclusions.any { exclude ->
|
||||
dir.toString().contains(exclude, true)
|
||||
}
|
||||
) return FileVisitResult.SKIP_SUBTREE
|
||||
|
||||
pathToSeries[dir] = Series(
|
||||
name = dir.fileName.toString(),
|
||||
name = dir.fileName?.toString() ?: dir.toString(),
|
||||
url = dir.toUri().toURL(),
|
||||
fileLastModified = attrs.getUpdatedTime()
|
||||
)
|
||||
|
@ -70,6 +70,28 @@ class FileSystemScannerTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given root directory as filesystem root when scanning then return 1 series containing those files as books`() {
|
||||
Jimfs.newFileSystem(Configuration.unix()).use { fs ->
|
||||
// given
|
||||
val root = fs.getPath("/")
|
||||
|
||||
val files = listOf("file1.cbz", "file2.cbz")
|
||||
files.forEach { Files.createFile(root.resolve(it)) }
|
||||
|
||||
// when
|
||||
val scan = scanner.scanRootFolder(root).series
|
||||
val series = scan.keys.first()
|
||||
val books = scan.getValue(series)
|
||||
|
||||
// then
|
||||
assertThat(scan).hasSize(1)
|
||||
assertThat(series.name).isEqualTo("/")
|
||||
assertThat(books).hasSize(2)
|
||||
assertThat(books.map { it.name }).containsExactlyInAnyOrderElementsOf(files.map { FilenameUtils.removeExtension(it) })
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given directory with unsupported files when scanning then return a series excluding those files as books`() {
|
||||
Jimfs.newFileSystem(Configuration.unix()).use { fs ->
|
||||
|
Loading…
Reference in New Issue
Block a user