Tweak debuggina and skip unnecessary step in Item.getFile()

This commit is contained in:
Dan Stillman 2009-01-22 17:12:34 +00:00
parent 8e07effc0d
commit bf39f716f6

View file

@ -2169,7 +2169,7 @@ Zotero.Item.prototype.getFile = function(row, skipExistsCheck) {
row.linkMode == Zotero.Attachments.LINK_MODE_IMPORTED_FILE) { row.linkMode == Zotero.Attachments.LINK_MODE_IMPORTED_FILE) {
try { try {
if (row.path.indexOf("storage:") == -1) { if (row.path.indexOf("storage:") == -1) {
Zotero.debug("Invalid attachment path '" + row.path + "'"); Zotero.debug("Invalid attachment path '" + row.path + "'", 2);
throw ('Invalid path'); throw ('Invalid path');
} }
// Strip "storage:" // Strip "storage:"
@ -2177,15 +2177,12 @@ Zotero.Item.prototype.getFile = function(row, skipExistsCheck) {
var file = Zotero.Attachments.getStorageDirectory(this.id); var file = Zotero.Attachments.getStorageDirectory(this.id);
file.QueryInterface(Components.interfaces.nsILocalFile); file.QueryInterface(Components.interfaces.nsILocalFile);
file.setRelativeDescriptor(file, path); file.setRelativeDescriptor(file, path);
if (!file.exists()) {
Zotero.debug("Attachment file '" + path + "' not found");
throw ('File not found');
}
} }
catch (e) { catch (e) {
// See if this is a persistent path // See if this is a persistent path
// (deprecated for imported attachments) // (deprecated for imported attachments)
Zotero.debug('Trying as persistent descriptor'); Zotero.debug('Trying as persistent descriptor');
try { try {
var file = Components.classes["@mozilla.org/file/local;1"]. var file = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile); createInstance(Components.interfaces.nsILocalFile);
@ -2198,7 +2195,7 @@ Zotero.Item.prototype.getFile = function(row, skipExistsCheck) {
} }
} }
catch (e) { catch (e) {
Zotero.debug('Invalid persistent descriptor'); Zotero.debug('Invalid persistent descriptor', 2);
return false; return false;
} }
} }
@ -2224,13 +2221,14 @@ Zotero.Item.prototype.getFile = function(row, skipExistsCheck) {
} }
} }
catch (e) { catch (e) {
Zotero.debug('Invalid relative descriptor'); Zotero.debug('Invalid relative descriptor', 2);
return false; return false;
} }
} }
} }
if (!skipExistsCheck && !file.exists()) { if (!skipExistsCheck && !file.exists()) {
Zotero.debug("Attachment file not found", 2);
return false; return false;
} }