mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Only write sync timestamp after a complete sync
This commit is contained in:
@@ -585,7 +585,7 @@ _.extend(RemoteCatalog.prototype, {
|
||||
},
|
||||
|
||||
//Given data from troposphere, add it into the local store
|
||||
insertData: function(serverData) {
|
||||
insertData: function(serverData, syncComplete) {
|
||||
var self = this;
|
||||
return self.db.runInTransaction(function (txn) {
|
||||
self.tablePackages.upsert(txn, serverData.collections.packages);
|
||||
@@ -599,8 +599,10 @@ _.extend(RemoteCatalog.prototype, {
|
||||
syncToken._id = "1"; //Add fake _id so it fits the pattern
|
||||
self.tableSyncToken.upsert(txn, [syncToken]);
|
||||
|
||||
var lastSync = { timestamp: Date.now() };
|
||||
self._setMetadata(txn, METADATA_LAST_SYNC, lastSync);
|
||||
if (syncComplete) {
|
||||
var lastSync = {timestamp: Date.now()};
|
||||
self._setMetadata(txn, METADATA_LAST_SYNC, lastSync);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -221,7 +221,8 @@ _updateServerPackageData = function (dataStore, options) {
|
||||
|
||||
// We always write to the data store; the fact there is no data is itself data!
|
||||
// e.g. the last-refresh timestamp
|
||||
dataStore.insertData(remoteData);
|
||||
var syncComplete = _.isEqual(remoteData.collections, {}) || remoteData.upToDate;
|
||||
dataStore.insertData(remoteData, syncComplete);
|
||||
|
||||
// If there is no new data from the server, don't bother writing things to
|
||||
// disk (unless we were just told to reset everything).
|
||||
|
||||
Reference in New Issue
Block a user