Fix file sync error on Windows

This commit is contained in:
Dan Stillman 2013-08-08 14:15:41 -04:00
parent 4af73f4a52
commit 610017e4df

View File

@ -1027,16 +1027,21 @@ Zotero.Sync.Storage = new function () {
return Zotero.Utilities.Internal.md5Async(file) return Zotero.Utilities.Internal.md5Async(file)
.then(function (fileHash) { .then(function (fileHash) {
if (row.hash && row.hash == fileHash) { if (row.hash && row.hash == fileHash) {
Zotero.debug("Mod time didn't match (" + fmtime + "!=" + mtime + ") " // We have to close the file before modifying it from the main
+ "but hash did for " + nsIFile.leafName + " for item " + lk // thread (at least on Windows, where assigning lastModifiedTime
+ " -- updating file mod time"); // throws an NS_ERROR_FILE_IS_LOCKED otherwise)
try { return Q(file.close())
nsIFile.lastModifiedTime = row.mtime; .then(function () {
} Zotero.debug("Mod time didn't match (" + fmtime + "!=" + mtime + ") "
catch (e) { + "but hash did for " + nsIFile.leafName + " for item " + lk
Zotero.File.checkFileAccessError(e, nsIFile, 'update'); + " -- updating file mod time");
} try {
return; nsIFile.lastModifiedTime = row.mtime;
}
catch (e) {
Zotero.File.checkFileAccessError(e, nsIFile, 'update');
}
});
} }
// Mark file for upload // Mark file for upload