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