This commit is contained in:
+3
-1
@@ -33,7 +33,9 @@ public class LibraryFileHelper {
|
|||||||
boolean supportsSupplementaryFiles = processor.supportsSupplementaryFiles();
|
boolean supportsSupplementaryFiles = processor.supportsSupplementaryFiles();
|
||||||
|
|
||||||
try (Stream<Path> stream = Files.walk(libraryPath, FileVisitOption.FOLLOW_LINKS)) {
|
try (Stream<Path> stream = Files.walk(libraryPath, FileVisitOption.FOLLOW_LINKS)) {
|
||||||
return stream.filter(Files::isRegularFile)
|
return stream
|
||||||
|
.filter(Files::isReadable)
|
||||||
|
.filter(Files::isRegularFile)
|
||||||
.filter(path -> !FileUtils.shouldIgnore(path))
|
.filter(path -> !FileUtils.shouldIgnore(path))
|
||||||
.map(fullPath -> {
|
.map(fullPath -> {
|
||||||
String fileName = fullPath.getFileName().toString();
|
String fileName = fullPath.getFileName().toString();
|
||||||
|
|||||||
@@ -8,8 +8,11 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import com.adityachandel.booklore.model.entity.BookEntity;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -60,12 +63,19 @@ public class FileUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<String> systemDirs = Arrays.asList(
|
||||||
|
// synology
|
||||||
|
"#recycle",
|
||||||
|
"@eaDir",
|
||||||
|
// calibre
|
||||||
|
".caltrash"
|
||||||
|
);
|
||||||
public boolean shouldIgnore(Path path) {
|
public boolean shouldIgnore(Path path) {
|
||||||
if (!path.getFileName().toString().isEmpty() && path.getFileName().toString().charAt(0) == '.') {
|
if (!path.getFileName().toString().isEmpty() && path.getFileName().toString().charAt(0) == '.') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (Path part : path) {
|
for (Path part : path) {
|
||||||
if (".caltrash".equals(part.toString())) {
|
if (systemDirs.contains(part.toString())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user