1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-06 09:19:22 +02:00

Deleted uneeded file

This commit is contained in:
Laurent Cozic
2017-12-03 23:06:02 +00:00
parent aec556ff7d
commit 0eac8b25e1
3 changed files with 427 additions and 381 deletions

View File

@@ -201,11 +201,11 @@ class BaseModel {
let output = {};
let type = null;
for (let n in newModel) {
if (!newModel.hasOwnProperty(n)) continue;
if (n == 'type_') {
type = n;
type = newModel[n];
continue;
}
if (!newModel.hasOwnProperty(n)) continue;
if (!(n in oldModel) || newModel[n] !== oldModel[n]) {
output[n] = newModel[n];
}
@@ -214,6 +214,12 @@ class BaseModel {
return output;
}
static modelsAreSame(oldModel, newModel) {
const diff = this.diffObjects(oldModel, newModel);
delete diff.type_;
return !Object.getOwnPropertyNames(diff).length;
}
static saveQuery(o, options) {
let temp = {}
let fieldNames = this.fieldNames();

View File

@@ -221,6 +221,8 @@ class Synchronizer {
}
} else {
if (remote.updated_time > local.sync_time) {
console.info('CONFLICT', local.sync_time, remote.updated_time);
// Since, in this loop, we are only dealing with items that require sync, if the
// remote has been modified after the sync time, it means both items have been
// modified and so there's a conflict.
@@ -266,6 +268,8 @@ class Synchronizer {
// await this.api().setTimestamp(tempPath, local.updated_time);
// await this.api().move(tempPath, path);
console.info('Update remote: ', local);
await this.api().put(path, content);
await this.api().setTimestamp(path, local.updated_time);
await ItemClass.saveSyncTime(syncTargetId, local, time.unixMs());
@@ -421,6 +425,11 @@ class Synchronizer {
let ItemClass = BaseItem.itemClass(content);
content = ItemClass.filter(content);
// 2017-12-03: This was added because the new user_updated_time and user_created_time properties were added
// to the items. However changing the database is not enough since remote items that haven't been synced yet
// will not have these properties and, since they are required, it would cause a problem. So this check
// if they are present and, if not, set them to a reasonable default.
// Let's leave these two lines for 6 months, by which time all the clients should have been synced.
if (!content.user_updated_time) content.user_updated_time = content.updated_time;
if (!content.user_created_time) content.user_created_time = content.created_time;
@@ -448,6 +457,9 @@ class Synchronizer {
await this.api().get(remoteResourceContentPath, { path: localResourceContentPath, target: 'file' });
}
// if (!newContent.user_updated_time) newContent.user_updated_time = newContent.updated_time;
// if (!newContent.user_created_time) newContent.user_created_time = newContent.created_time;
await ItemClass.save(newContent, options);
} else if (action == 'deleteLocal') {