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,6 +1027,11 @@ 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) {
// We have to close the file before modifying it from the main
// thread (at least on Windows, where assigning lastModifiedTime
// throws an NS_ERROR_FILE_IS_LOCKED otherwise)
return Q(file.close())
.then(function () {
Zotero.debug("Mod time didn't match (" + fmtime + "!=" + mtime + ") " Zotero.debug("Mod time didn't match (" + fmtime + "!=" + mtime + ") "
+ "but hash did for " + nsIFile.leafName + " for item " + lk + "but hash did for " + nsIFile.leafName + " for item " + lk
+ " -- updating file mod time"); + " -- updating file mod time");
@ -1036,7 +1041,7 @@ Zotero.Sync.Storage = new function () {
catch (e) { catch (e) {
Zotero.File.checkFileAccessError(e, nsIFile, 'update'); Zotero.File.checkFileAccessError(e, nsIFile, 'update');
} }
return; });
} }
// Mark file for upload // Mark file for upload