www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 75682596df66c69fcaf169757395d12193853d20
parent 012229552ebd1c890c05a74b055831f7605c474b
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu, 26 Jun 2008 04:14:02 +0000

Fix a few potential attachment errors



Diffstat:
Mchrome/content/zotero/xpcom/data/item.js | 2++
Mchrome/content/zotero/xpcom/schema.js | 26+++++++++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js @@ -2166,6 +2166,7 @@ Zotero.Item.prototype.getFile = function(row, skipExistsCheck) { } catch (e) { Zotero.debug('Invalid persistent descriptor'); + return false; } } } @@ -2191,6 +2192,7 @@ Zotero.Item.prototype.getFile = function(row, skipExistsCheck) { } catch (e) { Zotero.debug('Invalid relative descriptor'); + return false; } } } diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js @@ -1569,6 +1569,22 @@ Zotero.Schema = new function(){ continue; } if (keys[id]) { + var renameTarget = storage37.clone(); + renameTarget.append(keys[id]); + if (renameTarget.exists()) { + if (!orphaned.exists()) { + orphaned.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755); + } + var target = orphaned.clone(); + target.append(keys[id]); + var newName = null; + if (target.exists()) { + target.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644); + newName = target.leafName; + target.remove(null); + } + renameTarget.moveTo(orphaned, newName); + } file.moveTo(null, keys[id]); moveReport += keys[id] + ' ' + id + "\n"; } @@ -1576,7 +1592,15 @@ Zotero.Schema = new function(){ if (!orphaned.exists()) { orphaned.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755); } - file.moveTo(orphaned, null); + var target = orphaned.clone(); + target.append(file.leafName); + var newName = null; + if (target.exists()) { + target.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644); + newName = target.leafName; + target.remove(null); + } + file.moveTo(orphaned, newName); } movedFiles37[id] = file; }