Merge pull request #97 from ThomasFok/fix/ignore_deleted_files

acx - Filter out deleted file entries
This commit is contained in:
A2 Geek 2023-02-12 12:38:47 -06:00 committed by GitHub
commit 1b3a5546ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 0 deletions

View File

@ -92,6 +92,7 @@ public class ImportCommand extends ReadWriteDiskCommandOptions {
for (String dir : dirs) { for (String dir : dirs) {
Optional<FileEntry> fileEntry = directory.getFiles().stream() Optional<FileEntry> fileEntry = directory.getFiles().stream()
.filter(f -> dir.equalsIgnoreCase(f.getFilename())) .filter(f -> dir.equalsIgnoreCase(f.getFilename()))
.filter(f -> !f.isDeleted())
.findFirst(); .findFirst();
Optional<DirectoryEntry> dirEntry = fileEntry Optional<DirectoryEntry> dirEntry = fileEntry
.filter(FileEntry::isDirectory) .filter(FileEntry::isDirectory)

View File

@ -54,6 +54,7 @@ public class RmdirCommand extends ReadWriteDiskCommandOptions {
final String pathName = formattedDisk.getSuggestedFilename(paths[i]); final String pathName = formattedDisk.getSuggestedFilename(paths[i]);
Optional<FileEntry> optEntry = directory.getFiles().stream() Optional<FileEntry> optEntry = directory.getFiles().stream()
.filter(entry -> entry.getFilename().equalsIgnoreCase(pathName)) .filter(entry -> entry.getFilename().equalsIgnoreCase(pathName))
.filter(entry -> !entry.isDeleted())
.findFirst(); .findFirst();
if (optEntry.isPresent()) { if (optEntry.isPresent()) {

View File

@ -56,6 +56,7 @@ public class FileUtils {
Optional<FileEntry> targetFile = targetParent.getFiles() Optional<FileEntry> targetFile = targetParent.getFiles()
.stream() .stream()
.filter(fileEntry -> name.equals(fileEntry.getFilename())) .filter(fileEntry -> name.equals(fileEntry.getFilename()))
.filter(fileEntry -> !fileEntry.isDeleted())
.findFirst(); .findFirst();
Optional<DirectoryEntry> targetDir = targetFile Optional<DirectoryEntry> targetDir = targetFile
.filter(FileEntry::isDirectory) .filter(FileEntry::isDirectory)
@ -89,6 +90,7 @@ public class FileUtils {
String sanitizedName = directory.getFormattedDisk().getSuggestedFilename(sourceName); String sanitizedName = directory.getFormattedDisk().getSuggestedFilename(sourceName);
final Optional<FileEntry> fileEntry = directory.getFiles().stream() final Optional<FileEntry> fileEntry = directory.getFiles().stream()
.filter(entry -> entry.getFilename().equals(sanitizedName)) .filter(entry -> entry.getFilename().equals(sanitizedName))
.filter(entry -> !entry.isDeleted())
.findFirst(); .findFirst();
final FileEntry targetFile; final FileEntry targetFile;