Automatic attachment file renaming changes
Automatic renaming is now done for dragging of an external file onto an
item (as added in 7cb95f41
) as well as dragging as a linked file,
dragging a non-native (not text or HTML) URL, "Attach Link to File…",
"Attach Stored Copy of File…", and "Retrieve Metadata for PDF". It only
applies if a single file is being added and if the parent item has no
non-HTML attachments. By default, the renaming only applies to PDFs, but
this can be changed with the renameAttachmentFiles.automatic.fileTypes
hidden pref.
A new General pref, "Automatically rename attachment files using parent
metadata", controls whether the renaming happens.
Files saved via web translators are renamed regardless of this pref,
because they would often be gibberish otherwise.
Closes #113
This commit is contained in:
parent
68879a0ffc
commit
f8b41c971c
10 changed files with 335 additions and 96 deletions
|
@ -27,31 +27,36 @@ describe("PDF Recognition", function() {
|
|||
}
|
||||
});
|
||||
|
||||
it("should recognize a PDF", function* () {
|
||||
it("should recognize a PDF", async function () {
|
||||
this.timeout(30000);
|
||||
// Import the PDF
|
||||
var testdir = getTestDataDirectory();
|
||||
testdir.append("recognizePDF_test_GS.pdf");
|
||||
var item = yield Zotero.Attachments.importFromFile({
|
||||
var attachment = await Zotero.Attachments.importFromFile({
|
||||
file: testdir
|
||||
});
|
||||
|
||||
// Recognize the PDF
|
||||
win.ZoteroPane.recognizeSelected();
|
||||
|
||||
var addedIDs = yield waitForItemEvent("add");
|
||||
var modifiedIDs = yield waitForItemEvent("modify");
|
||||
var addedIDs = await waitForItemEvent("add");
|
||||
var modifiedIDs = await waitForItemEvent("modify");
|
||||
assert.lengthOf(addedIDs, 1);
|
||||
var item = Zotero.Items.get(addedIDs[0]);
|
||||
assert.equal(item.getField("title"), "Scaling study of an improved fermion action on quenched lattices");
|
||||
assert.lengthOf(modifiedIDs, 2);
|
||||
|
||||
yield Zotero.Promise.delay(0);
|
||||
|
||||
// Wait for status to show as complete
|
||||
var progressWindow = getWindows("chrome://zotero/content/recognizePDFDialog.xul")[0];
|
||||
var completeStr = Zotero.getString("recognizePDF.complete.label");
|
||||
while (progressWindow.document.getElementById("label").value != completeStr) {
|
||||
await Zotero.Promise.delay(20);
|
||||
}
|
||||
|
||||
// The file should have been renamed
|
||||
assert.equal(
|
||||
progressWindow.document.getElementById("label").value,
|
||||
Zotero.getString("recognizePDF.complete.label")
|
||||
attachment.attachmentFilename,
|
||||
Zotero.Attachments.getFileBaseNameFromItem(item) + '.pdf'
|
||||
);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue