Skip to content

Commit

Permalink
Add unchecking files after import in UnlinkedFilesDialogViewModel.java
Browse files Browse the repository at this point in the history
- Remove usage of containsEntryWithLinkedFile in UnlinkedFilesDialogView.java
  • Loading branch information
rocket125 committed Feb 16, 2025
1 parent 798bda5 commit b61afce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ void scanFiles() {
@FXML
void startImport() {
viewModel.startImport();

// Uncheck selected files
unlinkedFilesList.getCheckModel().clearChecks();
}

@FXML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.function.Predicate;
Expand Down Expand Up @@ -43,7 +42,6 @@
import org.jabref.logic.util.StandardFileType;
import org.jabref.logic.util.TaskExecutor;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.LinkedFile;
import org.jabref.model.util.FileUpdateMonitor;

import de.saxsys.mvvmfx.utils.validation.FunctionBasedValidator;
Expand Down Expand Up @@ -146,22 +144,19 @@ public void startSearch() {
}

public void startImport() {
List<Path> fileList = new ArrayList<>(checkedFileListProperty
List<Path> fileList = checkedFileListProperty
.stream()
.map(TreeItem::getValue)
.map(FileNodeViewModel::getPath)
.filter(Files::isRegularFile)
.toList());
.toList();

if (fileList.isEmpty()) {
LOGGER.warn("There are no valid files checked for import");
return;
}
resultList.clear();

// Removes duplicate files before importing
fileList.removeIf(path -> bibDatabase.getDatabase().containsEntryWithLinkedFile(new LinkedFile(path)));

importFilesBackgroundTask = importHandler
.importFilesInBackground(fileList, bibDatabase, preferences.getFilePreferences(), TransferMode.LINK)
.onRunning(() -> {
Expand Down

0 comments on commit b61afce

Please sign in to comment.