Fix error clearing full-text cache files and update deprecated calls

This commit is contained in:
Dan Stillman 2009-05-22 04:48:12 +00:00
parent 4228132af2
commit 305d5e18a7

View file

@ -488,13 +488,11 @@ Zotero.Fulltext = new function(){
var file = i.getFile(); var file = i.getFile();
if (!file){ if (!file){
Zotero.debug("No file to index for item " + i.getID() Zotero.debug("No file to index for item " + i.id + " in Fulltext.indexItems()");
+ " in Fulltext.indexItems()");
continue; continue;
} }
this.indexFile(file, i.getAttachmentMIMEType(), this.indexFile(file, i.attachmentMIMEType, i.attachmentCharset, i.id, !complete);
i.getAttachmentCharset(), i.getID(), !complete);
} }
Zotero.DB.commitTransaction(); Zotero.DB.commitTransaction();
@ -601,10 +599,9 @@ Zotero.Fulltext = new function(){
continue; continue;
} }
var mimeType = i.getAttachmentMIMEType(); var mimeType = i.attachmentMIMEType;
if (isCachedMIMEType(mimeType)) { if (isCachedMIMEType(mimeType)) {
var file = _getItemCacheFile(i.getID()); var file = _getItemCacheFile(i.id);
if (!file.exists()) { if (!file.exists()) {
continue; continue;
} }
@ -621,7 +618,7 @@ Zotero.Fulltext = new function(){
} }
} }
var charset = i.getAttachmentCharset(); var charset = i.attachmentCharset;
} }
var match = this.findTextInFile(file, charset, searchText, mode); var match = this.findTextInFile(file, charset, searchText, mode);
@ -695,7 +692,7 @@ Zotero.Fulltext = new function(){
*/ */
function getTotalCharsFromFile(itemID) { function getTotalCharsFromFile(itemID) {
var item = Zotero.Items.get(itemID); var item = Zotero.Items.get(itemID);
switch (item.getAttachmentMIMEType()) { switch (item.attachmentMIMEType) {
case 'application/pdf': case 'application/pdf':
var file = Zotero.Attachments.getStorageDirectory(itemID); var file = Zotero.Attachments.getStorageDirectory(itemID);
file.append(this.pdfConverterCacheFile); file.append(this.pdfConverterCacheFile);
@ -742,7 +739,7 @@ Zotero.Fulltext = new function(){
throw ('Item ' + itemID + ' is not an attachment in Zotero.Fulltext.getIndexedState()'); throw ('Item ' + itemID + ' is not an attachment in Zotero.Fulltext.getIndexedState()');
} }
switch (item.getAttachmentMIMEType()) { switch (item.attachmentMIMEType) {
// Use pages for PDFs // Use pages for PDFs
case 'application/pdf': case 'application/pdf':
var pages = this.getPages(itemID); var pages = this.getPages(itemID);
@ -827,7 +824,7 @@ Zotero.Fulltext = new function(){
*/ */
function canReindex(itemID) { function canReindex(itemID) {
var item = Zotero.Items.get(itemID); var item = Zotero.Items.get(itemID);
if (item && item.isAttachment() && item.getAttachmentLinkMode() != if (item && item.isAttachment() && item.attachmentLinkMode !=
Zotero.Attachments.LINK_MODE_LINKED_URL) { Zotero.Attachments.LINK_MODE_LINKED_URL) {
switch (this.getIndexedState(itemID)) { switch (this.getIndexedState(itemID)) {
case this.INDEX_STATE_UNAVAILABLE: case this.INDEX_STATE_UNAVAILABLE:
@ -913,11 +910,11 @@ Zotero.Fulltext = new function(){
} }
Zotero.debug('Clearing full-text cache file for item ' + itemID); Zotero.debug('Clearing full-text cache file for item ' + itemID);
switch (item.getAttachmentMIMEType()) { switch (item.attachmentMIMEType) {
case 'application/pdf': case 'application/pdf':
var cacheFile = _getItemCacheFile(); var cacheFile = _getItemCacheFile(itemID);
if (cacheFile.exists()) { if (cacheFile.exists()) {
cacheFile.remove(null); cacheFile.remove(false);
} }
break; break;
} }