-
Notifications
You must be signed in to change notification settings - Fork 17
Persist group membership in folder libraries and make pair renames opt-in #769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: directory-split
Are you sure you want to change the base?
Changes from all commits
18f87e9
37b00f1
ebb0201
030485f
b423cae
e11f3bf
1f4c552
176c3db
73ef5ad
7e49b42
7b2b3d7
6f26eb4
5ece054
c5f12b8
6ba92f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| import org.jabref.gui.clipboard.ClipBoardManager; | ||
| import org.jabref.gui.desktop.os.NativeDesktop; | ||
| import org.jabref.gui.exporter.SaveDatabaseAction; | ||
| import org.jabref.gui.externalfiles.AutoRenameFileOnEntryChange; | ||
| import org.jabref.gui.git.GitConflictResolverDialog; | ||
| import org.jabref.gui.git.GuiGitConflictResolverStrategy; | ||
| import org.jabref.gui.preferences.GuiPreferences; | ||
|
|
@@ -160,8 +161,12 @@ private void showLibraryTab(DirectoryLibraryScanner.ScanResult scanResult, PdfEn | |
| libraryTab.updateTabTitle(false); | ||
|
|
||
| BibDatabaseContext databaseContext = scanResult.databaseContext(); | ||
| Function<BibEntry, Optional<String>> fileNameGenerator = entry -> FileUtil.createFileNameFromPattern( | ||
| databaseContext.getDatabase(), entry, preferences.getFilePreferences().getFileNamePattern()); | ||
| // Evaluated per write, so a changed preference (global or library) takes effect immediately | ||
| // [impl->req~directory-library.pattern-rename~2] | ||
| Function<BibEntry, Optional<String>> fileNameGenerator = entry -> | ||
| AutoRenameFileOnEntryChange.isEnabled(databaseContext, preferences.getFilePreferences()) | ||
| ? FileUtil.createFileNameFromPattern(databaseContext.getDatabase(), entry, preferences.getFilePreferences().getFileNamePattern()) | ||
| : Optional.empty(); | ||
|
qodo-free-for-open-source-projects[bot] marked this conversation as resolved.
qodo-free-for-open-source-projects[bot] marked this conversation as resolved.
Comment on lines
+167
to
+169
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 9. Long names split folder file pairs The directory-library fileNameGenerator returns the raw pattern basename while AutoRenameFileOnEntryChange sends the same entry through LinkedFileHandler, which truncates the PDF filename to 255 characters. When an enabled library override processes a sufficiently long generated name, the PDF moves to the truncated basename before SidecarWriteBack looks for it under the old basename, so only the sidecar receives the untruncated name and the pair is no longer associated. Agent Prompt
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Generated with Claude Code
qodo-free-for-open-source-projects[bot] marked this conversation as resolved.
|
||
| GuiGitConflictResolverStrategy conflictResolver = new GuiGitConflictResolverStrategy( | ||
| new GitConflictResolverDialog(dialogService, preferences, stateManager)); | ||
| DirectoryLibrarySynchronizer synchronizer = new DirectoryLibrarySynchronizer( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,7 @@ public class GeneralPropertiesViewModel implements PropertiesTabViewModel { | |
| private final StringProperty userSpecificFileDirectoryProperty = new SimpleStringProperty(""); | ||
| private final StringProperty laTexFileDirectoryProperty = new SimpleStringProperty(""); | ||
| private final StringProperty keywordSeparatorProperty = new SimpleStringProperty(""); | ||
| private final ObjectProperty<Optional<Boolean>> autoRenameFilesOnChangeProperty = new SimpleObjectProperty<>(Optional.empty()); | ||
|
|
||
| private final Validator librarySpecificFileDirectoryValidator; | ||
| private final Validator userSpecificFileDirectoryValidator; | ||
|
|
@@ -91,6 +92,7 @@ public void setValues(MetaData metaData) { | |
| userSpecificFileDirectoryProperty.setValue(metaData.getUserFileDirectory(preferences.getFilePreferences().getUserAndHost()).orElse("").trim()); | ||
| laTexFileDirectoryProperty.setValue(metaData.getLatexFileDirectory(preferences.getFilePreferences().getUserAndHost()).map(Path::toString).orElse("")); | ||
| keywordSeparatorProperty.setValue(metaData.getKeywordSeparator().map(Object::toString).orElse("")); | ||
| autoRenameFilesOnChangeProperty.setValue(metaData.getAutoRenameFilesOnChange()); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -120,6 +122,7 @@ public void storeSettings(MetaData metaData) { | |
| } | ||
|
|
||
| storeKeywordSeparator(metaData); | ||
| autoRenameFilesOnChangeProperty.getValue().ifPresentOrElse(metaData::setAutoRenameFilesOnChange, metaData::clearAutoRenameFilesOnChange); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. Shared libraries keep stale rename rules storeSettings clears the optional override, but MetaDataSerializer then omits its key while shared metadata persistence only upserts emitted keys and remote parsing never clears an absent key. When a user switches back to the global preference in a shared library, other clients can indefinitely retain the previous override and continue renaming or not renaming linked files against the current setting. Agent Prompt
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Generated with Claude Code |
||
| } | ||
|
|
||
| /// The separator and the group definitions the migration rewrites are both metadata, so the | ||
|
|
@@ -225,6 +228,10 @@ public StringProperty keywordSeparatorProperty() { | |
| return this.keywordSeparatorProperty; | ||
| } | ||
|
|
||
| public ObjectProperty<Optional<Boolean>> autoRenameFilesOnChangeProperty() { | ||
| return this.autoRenameFilesOnChangeProperty; | ||
| } | ||
|
|
||
| private Path getBrowseDirectory(String configuredDir) { | ||
| Optional<Path> libPath = this.databaseContext.getDatabasePath(); | ||
| Path workingDir = preferences.getFilePreferences().getWorkingDirectory(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.