- Fix error syncing empty files
- Clarify quota message to say that metadata will continue to sync - Fix some other problem that I don't remember
This commit is contained in:
parent
4407275401
commit
7e6784a739
4 changed files with 29 additions and 4 deletions
|
@ -2563,7 +2563,7 @@ Zotero.Item.prototype.getFilename = function () {
|
||||||
*
|
*
|
||||||
* -1 Destination file exists -- use _force_ to overwrite
|
* -1 Destination file exists -- use _force_ to overwrite
|
||||||
* -2 Error renaming
|
* -2 Error renaming
|
||||||
* false Attachment file not found or other error
|
* false Attachment file not found
|
||||||
*/
|
*/
|
||||||
Zotero.Item.prototype.renameAttachmentFile = function(newName, overwrite) {
|
Zotero.Item.prototype.renameAttachmentFile = function(newName, overwrite) {
|
||||||
var file = this.getFile();
|
var file = this.getFile();
|
||||||
|
@ -2591,10 +2591,16 @@ Zotero.Item.prototype.renameAttachmentFile = function(newName, overwrite) {
|
||||||
|
|
||||||
file.moveTo(null, newName);
|
file.moveTo(null, newName);
|
||||||
// Update mod time and clear hash so the file syncs
|
// Update mod time and clear hash so the file syncs
|
||||||
|
// TODO: use an integer counter instead of mod time for change detection
|
||||||
dest.lastModifiedTime = new Date();
|
dest.lastModifiedTime = new Date();
|
||||||
this.relinkAttachmentFile(dest);
|
this.relinkAttachmentFile(dest);
|
||||||
|
|
||||||
|
Zotero.DB.beginTransaction();
|
||||||
|
|
||||||
Zotero.Sync.Storage.setSyncedHash(this.id, null, false);
|
Zotero.Sync.Storage.setSyncedHash(this.id, null, false);
|
||||||
|
Zotero.Sync.Storage.setSyncState(this.id, Zotero.Sync.Storage.SYNC_STATE_TO_UPLOAD);
|
||||||
|
|
||||||
|
Zotero.DB.commitTransaction();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,7 +164,7 @@ Zotero.Sync.Storage.Session.ZFS.prototype.downloadFile = function (request) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If not compressed, check hash, in case only timestamp changed
|
// If not compressed, check hash, in case only timestamp changed
|
||||||
else if (!info.compressed && Zotero.Utilities.prototype.md5(file) == syncHash) {
|
else if (!info.compressed && item.attachmentHash == syncHash) {
|
||||||
Zotero.debug("File hash matches remote file -- skipping download");
|
Zotero.debug("File hash matches remote file -- skipping download");
|
||||||
|
|
||||||
Zotero.DB.beginTransaction();
|
Zotero.DB.beginTransaction();
|
||||||
|
|
|
@ -39,16 +39,24 @@ Zotero.Sync = new function() {
|
||||||
|
|
||||||
|
|
||||||
this.init = function () {
|
this.init = function () {
|
||||||
|
Zotero.DB.beginTransaction();
|
||||||
|
|
||||||
var sql = "SELECT version FROM version WHERE schema='syncdeletelog'";
|
var sql = "SELECT version FROM version WHERE schema='syncdeletelog'";
|
||||||
if (!Zotero.DB.valueQuery(sql)) {
|
if (!Zotero.DB.valueQuery(sql)) {
|
||||||
sql = "SELECT COUNT(*) FROM syncDeleteLog";
|
sql = "SELECT COUNT(*) FROM syncDeleteLog";
|
||||||
if (Zotero.DB.valueQuery(sql)) {
|
if (Zotero.DB.valueQuery(sql)) {
|
||||||
throw ('syncDeleteLog not empty and no timestamp in Zotero.Sync.delete()');
|
throw ('syncDeleteLog not empty and no timestamp in Zotero.Sync.delete()');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var syncInitTime = Zotero.DB.transactionDate;
|
||||||
|
syncInitTime = Zotero.Date.toUnixTimestamp(syncInitTime);
|
||||||
|
|
||||||
sql = "INSERT INTO version VALUES ('syncdeletelog', ?)";
|
sql = "INSERT INTO version VALUES ('syncdeletelog', ?)";
|
||||||
Zotero.DB.query(sql, Zotero.Date.getUnixTimestamp());
|
Zotero.DB.query(sql, syncInitTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Zotero.DB.commitTransaction();
|
||||||
|
|
||||||
this.EventListener.init();
|
this.EventListener.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +144,10 @@ Zotero.Sync = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Last sync time is before start of log
|
// Last sync time is before start of log
|
||||||
|
Zotero.debug('==============');
|
||||||
|
Zotero.debug(lastSyncDate);
|
||||||
|
Zotero.debug(lastSyncDate + '');
|
||||||
|
Zotero.debug(syncLogStart);
|
||||||
if (lastSyncDate && new Date(syncLogStart * 1000) > lastSyncDate) {
|
if (lastSyncDate && new Date(syncLogStart * 1000) > lastSyncDate) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -716,7 +728,8 @@ Zotero.Sync.Runner = new function () {
|
||||||
if (e) {
|
if (e) {
|
||||||
if (e.error == Zotero.Error.ERROR_ZFS_OVER_QUOTA) {
|
if (e.error == Zotero.Error.ERROR_ZFS_OVER_QUOTA) {
|
||||||
// TODO: localize
|
// TODO: localize
|
||||||
message = "You have reached your Zotero File Storage quota. Some files were not synced.\n\n"
|
message = "You have reached your Zotero File Storage quota. Some files were not synced. "
|
||||||
|
+ "Other Zotero data will continue to sync to the server.\n\n"
|
||||||
+ "See your zotero.org account settings for additional storage options.";
|
+ "See your zotero.org account settings for additional storage options.";
|
||||||
|
|
||||||
buttonText = "Open Account Settings";
|
buttonText = "Open Account Settings";
|
||||||
|
|
|
@ -415,6 +415,12 @@ Zotero.Utilities.prototype.md5 = function(strOrFile, base64) {
|
||||||
ch.update(data, data.length);
|
ch.update(data, data.length);
|
||||||
}
|
}
|
||||||
else if (strOrFile instanceof Components.interfaces.nsIFile) {
|
else if (strOrFile instanceof Components.interfaces.nsIFile) {
|
||||||
|
// Otherwise throws (NS_ERROR_NOT_AVAILABLE) [nsICryptoHash.updateFromStream]
|
||||||
|
if (!strOrFile.fileSize) {
|
||||||
|
// MD5 for empty string
|
||||||
|
return "d41d8cd98f00b204e9800998ecf8427e";
|
||||||
|
}
|
||||||
|
|
||||||
var istream = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
var istream = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
||||||
.createInstance(Components.interfaces.nsIFileInputStream);
|
.createInstance(Components.interfaces.nsIFileInputStream);
|
||||||
// open for reading
|
// open for reading
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue