- Fix Zotero crash attempting to index an unindexable link attachment twice

- Log error on index failure, and include note about filenames with extended characters if applicable
This commit is contained in:
Dan Stillman 2010-01-27 09:47:08 +00:00
parent 49632d6110
commit 9193ab3e62
3 changed files with 23 additions and 13 deletions

View file

@ -1230,18 +1230,11 @@ var ZoteroPane = new function()
function reindexItem() { function reindexItem() {
var items = this.getSelectedItems(); var itemIDs = this.getSelectedItems(true);
if (!items) { if (!itemIDs) {
return; return;
} }
Zotero.Fulltext.indexItems(itemIDs, true);
for (var i=0; i<items.length; i++) {
if (!items[i].isAttachment()) {
continue;
}
var itemID = items[i].id;
Zotero.Fulltext.indexItems(itemID, true);
}
document.getElementById('zotero-attachment-box').updateItemIndexedState(); document.getElementById('zotero-attachment-box').updateItemIndexedState();
} }

View file

@ -1186,12 +1186,24 @@ Zotero.Attachments = new function(){
dir = dir.clone(); dir = dir.clone();
// If directory is empty or has only hidden files, delete it
var files = dir.directoryEntries; var files = dir.directoryEntries;
files.QueryInterface(Components.interfaces.nsIDirectoryEnumerator); files.QueryInterface(Components.interfaces.nsIDirectoryEnumerator);
if (!files.hasMoreElements()) { var empty = true;
dir.remove(false); while (files.hasMoreElements()) {
var file = files.getNext();
file.QueryInterface(Components.interfaces.nsIFile);
if (file.leafName[0] == '.') {
continue;
}
empty = false;
break;
} }
files.close(); files.close();
if (empty) {
dir.remove(true);
return;
}
// Create orphaned-files directory if it doesn't exist // Create orphaned-files directory if it doesn't exist
var orphaned = Zotero.getZoteroDirectory(); var orphaned = Zotero.getZoteroDirectory();

View file

@ -462,7 +462,12 @@ Zotero.Fulltext = new function(){
} }
if (!cacheFile.exists()) { if (!cacheFile.exists()) {
Zotero.debug("Cache file doesn't exist!"); var msg = file.leafName + " was not indexed";
if (!file.leafName.match(/^[\u0000-\u007F]$/)) {
msg += " -- PDFs with filenames containing extended characters cannot currently be indexed due to a Firefox limitation";
}
Zotero.debug(msg, 2);
Components.utils.reportError(msg);
return false; return false;
} }