You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-06 09:19:22 +02:00
Sync fixes
This commit is contained in:
@@ -7,6 +7,7 @@ import { vorpalUtils } from './vorpal-utils.js';
|
||||
import { Synchronizer } from 'lib/synchronizer.js';
|
||||
const locker = require('proper-lockfile');
|
||||
const fs = require('fs-extra');
|
||||
const osTmpdir = require('os-tmpdir');
|
||||
|
||||
class Command extends BaseCommand {
|
||||
|
||||
@@ -34,7 +35,7 @@ class Command extends BaseCommand {
|
||||
|
||||
static lockFile(filePath) {
|
||||
return new Promise((resolve, reject) => {
|
||||
locker.lock(filePath, (error, release) => {
|
||||
locker.lock(filePath, { stale: 1000 * 60 * 5 }, (error, release) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
@@ -61,7 +62,7 @@ class Command extends BaseCommand {
|
||||
async action(args) {
|
||||
this.releaseLockFn_ = null;
|
||||
|
||||
const lockFilePath = Setting.value('tempDir') + '/synclock';
|
||||
const lockFilePath = osTmpdir() + '/synclock';
|
||||
if (!await fs.pathExists(lockFilePath)) await fs.writeFile(lockFilePath, 'synclock');
|
||||
|
||||
if (await Command.isLocked(lockFilePath)) throw new Error(_('Synchronisation is already in progress.'));
|
||||
@@ -71,7 +72,7 @@ class Command extends BaseCommand {
|
||||
try {
|
||||
this.syncTarget_ = Setting.value('sync.target');
|
||||
if (args.options.target) this.syncTarget_ = args.options.target;
|
||||
|
||||
|
||||
let syncInitOptions = {};
|
||||
if (args.options['filesystem-path']) syncInitOptions['sync.filesystem.path'] = args.options['filesystem-path'];
|
||||
|
||||
@@ -100,6 +101,7 @@ class Command extends BaseCommand {
|
||||
options.context = context;
|
||||
let newContext = await sync.start(options);
|
||||
Setting.setValue('sync.context', JSON.stringify(newContext));
|
||||
|
||||
vorpalUtils.redrawDone();
|
||||
|
||||
await app().refreshCurrentFolder();
|
||||
|
||||
@@ -97,8 +97,8 @@ async function saveNoteResources(note) {
|
||||
let existingResource = await Resource.load(toSave.id);
|
||||
if (existingResource) continue;
|
||||
|
||||
await Resource.save(toSave, { isNew: true });
|
||||
await filePutContents(Resource.fullPath(toSave), resource.data)
|
||||
await Resource.save(toSave, { isNew: true });
|
||||
resourcesCreated++;
|
||||
}
|
||||
return resourcesCreated;
|
||||
|
||||
@@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Joplin-CLI 1.0.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-07-18 23:34+0100\n"
|
||||
"POT-Creation-Date: 2017-07-19 20:00+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -287,40 +287,40 @@ msgstr ""
|
||||
msgid "Displays summary about the notes and notebooks."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:24
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:26
|
||||
msgid "Synchronizes with remote storage."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:29
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:31
|
||||
msgid "Sync to provided target (defaults to sync.target config value)"
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:30
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:32
|
||||
msgid "For \"filesystem\" target only: Path to sync to."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:67
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:69
|
||||
msgid "Synchronisation is already in progress."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:92
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:96
|
||||
#, javascript-format
|
||||
msgid "Synchronization target: %s"
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:94
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:98
|
||||
msgid "Cannot initialize synchronizer."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:96
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:100
|
||||
msgid "Starting synchronization..."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:107
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:112
|
||||
msgid "Done."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:122
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:127
|
||||
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/synchronizer.js:60
|
||||
msgid "Cancelling..."
|
||||
msgstr ""
|
||||
|
||||
@@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Joplin-CLI 1.0.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-07-18 23:18+0100\n"
|
||||
"POT-Creation-Date: 2017-07-19 19:53+0100\n"
|
||||
"PO-Revision-Date: 2017-07-18 13:27+0100\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
@@ -310,42 +310,42 @@ msgstr "Assigner la valeur [value] à la propriété <name> de la <note> donnée
|
||||
msgid "Displays summary about the notes and notebooks."
|
||||
msgstr "Afficher un résumé des notes et carnets."
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:24
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:26
|
||||
msgid "Synchronizes with remote storage."
|
||||
msgstr "Synchroniser les notes et carnets."
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:29
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:31
|
||||
msgid "Sync to provided target (defaults to sync.target config value)"
|
||||
msgstr ""
|
||||
"Synchroniser avec la cible donnée (par défaut, la valeur de configuration "
|
||||
"`sync.target`)."
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:30
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:32
|
||||
msgid "For \"filesystem\" target only: Path to sync to."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:67
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:69
|
||||
msgid "Synchronisation is already in progress."
|
||||
msgstr "Synchronisation est déjà en cours."
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:92
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:96
|
||||
#, javascript-format
|
||||
msgid "Synchronization target: %s"
|
||||
msgstr "Cible de la synchronisation : %s"
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:94
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:98
|
||||
msgid "Cannot initialize synchronizer."
|
||||
msgstr "Impossible d'initialiser le synchroniseur."
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:96
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:100
|
||||
msgid "Starting synchronization..."
|
||||
msgstr "Commencement de la synchronisation..."
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:107
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:112
|
||||
msgid "Done."
|
||||
msgstr "Terminé."
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:122
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:127
|
||||
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/synchronizer.js:60
|
||||
msgid "Cancelling..."
|
||||
msgstr "Annulation..."
|
||||
|
||||
@@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Joplin-CLI 1.0.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-07-18 23:34+0100\n"
|
||||
"POT-Creation-Date: 2017-07-19 20:00+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -287,40 +287,40 @@ msgstr ""
|
||||
msgid "Displays summary about the notes and notebooks."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:24
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:26
|
||||
msgid "Synchronizes with remote storage."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:29
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:31
|
||||
msgid "Sync to provided target (defaults to sync.target config value)"
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:30
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:32
|
||||
msgid "For \"filesystem\" target only: Path to sync to."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:67
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:69
|
||||
msgid "Synchronisation is already in progress."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:92
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:96
|
||||
#, javascript-format
|
||||
msgid "Synchronization target: %s"
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:94
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:98
|
||||
msgid "Cannot initialize synchronizer."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:96
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:100
|
||||
msgid "Starting synchronization..."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:107
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:112
|
||||
msgid "Done."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:122
|
||||
#: /mnt/d/Web/www/joplin/CliClient/app/command-sync.js:127
|
||||
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/synchronizer.js:60
|
||||
msgid "Cancelling..."
|
||||
msgstr ""
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"url": "https://github.com/laurent22/joplin"
|
||||
},
|
||||
"url": "git://github.com/laurent22/joplin.git",
|
||||
"version": "0.8.58",
|
||||
"version": "0.8.62",
|
||||
"bin": {
|
||||
"joplin": "./main_launcher.js"
|
||||
},
|
||||
@@ -24,6 +24,7 @@
|
||||
"moment": "^2.18.1",
|
||||
"moment-timezone": "^0.5.13",
|
||||
"node-fetch": "^1.7.1",
|
||||
"os-tmpdir": "^1.0.2",
|
||||
"promise": "^7.1.1",
|
||||
"proper-lockfile": "^2.0.1",
|
||||
"query-string": "4.3.4",
|
||||
|
||||
@@ -6,6 +6,7 @@ import { setupDatabase, setupDatabaseAndSynchronizer, db, synchronizer, fileApi,
|
||||
import { Folder } from 'lib/models/folder.js';
|
||||
import { Note } from 'lib/models/note.js';
|
||||
import { Tag } from 'lib/models/tag.js';
|
||||
import { Database } from 'lib/database.js';
|
||||
import { Setting } from 'lib/models/setting.js';
|
||||
import { BaseItem } from 'lib/models/base-item.js';
|
||||
import { BaseModel } from 'lib/base-model.js';
|
||||
@@ -16,6 +17,8 @@ process.on('unhandledRejection', (reason, p) => {
|
||||
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 9000; // The first test is slow because the database needs to be built
|
||||
|
||||
const syncTargetId = Database.enumId('syncTarget', 'memory');
|
||||
|
||||
async function allItems() {
|
||||
let folders = await Folder.all();
|
||||
let notes = await Note.all();
|
||||
@@ -237,7 +240,7 @@ describe('Synchronizer', function() {
|
||||
expect(files.length).toBe(1);
|
||||
expect(files[0].path).toBe(Folder.systemPath(folder1));
|
||||
|
||||
let deletedItems = await BaseItem.deletedItems();
|
||||
let deletedItems = await BaseItem.deletedItems(syncTargetId);
|
||||
expect(deletedItems.length).toBe(0);
|
||||
|
||||
done();
|
||||
@@ -259,7 +262,7 @@ describe('Synchronizer', function() {
|
||||
await synchronizer().start();
|
||||
let items = await allItems();
|
||||
expect(items.length).toBe(1);
|
||||
let deletedItems = await BaseItem.deletedItems();
|
||||
let deletedItems = await BaseItem.deletedItems(syncTargetId);
|
||||
expect(deletedItems.length).toBe(0);
|
||||
|
||||
done();
|
||||
@@ -565,7 +568,7 @@ describe('Synchronizer', function() {
|
||||
await synchronizer().start();
|
||||
await Note.save({ id: n1.id, is_conflict: 1 });
|
||||
await Note.delete(n1.id);
|
||||
const deletedItems = await BaseItem.deletedItems();
|
||||
const deletedItems = await BaseItem.deletedItems(syncTargetId);
|
||||
|
||||
expect(deletedItems.length).toBe(0);
|
||||
|
||||
|
||||
@@ -72,6 +72,9 @@ function clearDatabase(id = null) {
|
||||
'DELETE FROM resources',
|
||||
'DELETE FROM tags',
|
||||
'DELETE FROM note_tags',
|
||||
|
||||
'DELETE FROM deleted_items',
|
||||
'DELETE FROM sync_items',
|
||||
];
|
||||
|
||||
return databases_[id].transactionExecBatch(queries);
|
||||
|
||||
@@ -666,7 +666,7 @@ babel-register@^6.24.1:
|
||||
mkdirp "^0.5.1"
|
||||
source-map-support "^0.4.2"
|
||||
|
||||
babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.23.0:
|
||||
babel-runtime@^6.18.0, babel-runtime@^6.22.0:
|
||||
version "6.23.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.23.0.tgz#0a9489f144de70efb3ce4300accdb329e2fc543b"
|
||||
dependencies:
|
||||
@@ -1641,7 +1641,7 @@ os-homedir@^1.0.0:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3"
|
||||
|
||||
os-tmpdir@^1.0.0, os-tmpdir@^1.0.1:
|
||||
os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user