mirror of
https://github.com/zotero/zotero.git
synced 2026-10-10 03:28:10 +00:00
Ensure automatic file renaming is enabled for group libraries (#5750)
This commit is contained in:
parent
56de1abb79
commit
aabac2576c
2 changed files with 20 additions and 7 deletions
|
|
@ -76,8 +76,8 @@ export async function renameFilesFromParent({ userLibrary = true, groupLibrary =
|
|||
let shouldRename = userLibrary && library.libraryType === 'user';
|
||||
|
||||
if (!shouldRename) {
|
||||
// for group libraries, check `autoRenameFiles` synced setting
|
||||
shouldRename = groupLibrary && Zotero.SyncedSettings.get(library.libraryID, 'autoRenameFiles');
|
||||
// for group libraries, this checks `autoRenameFiles` synced setting
|
||||
shouldRename = groupLibrary && Zotero.Attachments.isAutoRenameFilesEnabledForLibrary(library.libraryID);
|
||||
}
|
||||
|
||||
if (shouldRename) {
|
||||
|
|
|
|||
|
|
@ -2640,16 +2640,29 @@ Zotero.Attachments = new function () {
|
|||
return ext;
|
||||
};
|
||||
|
||||
this.isAutoRenameFilesEnabledForLibrary = function (libraryID) {
|
||||
// For user library, check preference
|
||||
if (libraryID === Zotero.Libraries.userLibraryID) {
|
||||
return Zotero.Prefs.get('autoRenameFiles');
|
||||
}
|
||||
// For other libraries, check synced setting
|
||||
const syncedSettingValue = Zotero.SyncedSettings.get(libraryID, 'autoRenameFiles');
|
||||
|
||||
// To preserve automatic file renaming ON by default in 8.0, where it is controlled by a synced setting, return true if the synced setting is unset
|
||||
if (syncedSettingValue === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return syncedSettingValue;
|
||||
};
|
||||
|
||||
this.shouldAutoRenameFile = function (isLink, libraryID = null) {
|
||||
if (libraryID === null) {
|
||||
Zotero.debug('Calling Zotero.Attachments.shouldAutoRenameFile without a libraryID is deprecated. Assuming user library.');
|
||||
libraryID = Zotero.Libraries.userLibraryID;
|
||||
}
|
||||
if (libraryID === Zotero.Libraries.userLibraryID && !Zotero.Prefs.get('autoRenameFiles')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (libraryID !== Zotero.Libraries.userLibraryID && !Zotero.SyncedSettings.get(libraryID, 'autoRenameFiles')) {
|
||||
|
||||
if (!this.isAutoRenameFilesEnabledForLibrary(libraryID)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue