1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00

All: Fixed sync issue and database migration issue

This commit is contained in:
Laurent Cozic 2017-12-02 15:18:15 +00:00
parent dd615d6a8f
commit 1830ee9fd2
2 changed files with 7 additions and 5 deletions

View File

@ -205,7 +205,9 @@ class JoplinDatabase extends Database {
const existingDatabaseVersions = [0, 1, 2, 3, 4, 5, 6, 7];
let currentVersionIndex = existingDatabaseVersions.indexOf(fromVersion);
if (currentVersionIndex == existingDatabaseVersions.length - 1) return false;
// currentVersionIndex < 0 if for the case where an old version of Joplin used with a newer
// version of the database, so that migration is not run in this case.
if (currentVersionIndex == existingDatabaseVersions.length - 1 || currentVersionIndex < 0) return false;
while (currentVersionIndex < existingDatabaseVersions.length - 1) {
const targetVersion = existingDatabaseVersions[currentVersionIndex + 1];

View File

@ -421,10 +421,13 @@ class Synchronizer {
let ItemClass = BaseItem.itemClass(content);
content = ItemClass.filter(content);
if (!content.user_updated_time) content.user_updated_time = content.updated_time;
if (!content.user_created_time) content.user_created_time = content.created_time;
let newContent = null;
if (action === 'createLocal') {
newContent = Object.assign({}, content);
newContent = Object.assign({}, content);
} else if (action === 'updateLocal') {
newContent = BaseModel.diffObjects(local, content);
newContent.type_ = content.type_;
@ -445,9 +448,6 @@ 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') {