1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Minor improvments

This commit is contained in:
Laurent Cozic 2018-10-30 00:17:50 +00:00
parent 7b85c33213
commit 990591cc80
5 changed files with 43 additions and 3 deletions

View File

@ -196,6 +196,7 @@ class Command extends BaseCommand {
// not going to be running in the background, so the resources need to be
// explicitely downloaded below.
if (!app().hasGui()) {
this.stdout(_('Downloading resources...'));
await ResourceFetcher.instance().fetchAll();
await ResourceFetcher.instance().waitForAllFinished();
}

View File

@ -25,6 +25,7 @@ npm test tests-build/ArrayUtils.js
npm test tests-build/EnexToMd.js
npm test tests-build/HtmlToMd.js
npm test tests-build/markdownUtils.js
npm test tests-build/models_BaseItem.js
npm test tests-build/models_Folder.js
npm test tests-build/models_Note.js
npm test tests-build/models_Tag.js

View File

@ -0,0 +1,37 @@
require('app-module-path').addPath(__dirname);
const { time } = require('lib/time-utils.js');
const { asyncTest, fileContentEqual, setupDatabase, setupDatabaseAndSynchronizer, db, synchronizer, fileApi, sleep, clearDatabase, switchClient, syncTargetId, objectsEqual, checkThrowAsync } = require('test-utils.js');
const Folder = require('lib/models/Folder.js');
const Note = require('lib/models/Note.js');
const Resource = require('lib/models/Resource.js');
const BaseModel = require('lib/BaseModel.js');
const { shim } = require('lib/shim');
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
});
async function allItems() {
let folders = await Folder.all();
let notes = await Note.all();
return folders.concat(notes);
}
describe('models_BaseItem', function() {
beforeEach(async (done) => {
await setupDatabaseAndSynchronizer(1);
await switchClient(1);
done();
});
it('should be able to exclude keys when syncing', asyncTest(async () => {
let folder1 = await Folder.save({ title: "folder1" });
let note1 = await Note.save({ title: 'ma note', parent_id: folder1.id });
await shim.attachFileToNote(note1, __dirname + '/../tests/support/photo.jpg');
let resource1 = (await Resource.all())[0];
console.info(await Resource.serializeForSync(resource1));
}));
});

View File

@ -25,7 +25,7 @@ describe('models_Resource', function() {
let note1 = await Note.save({ title: 'ma note', parent_id: folder1.id });
await shim.attachFileToNote(note1, __dirname + '/../tests/support/photo.jpg');
let resource1 = (await Resource.all())[0];
console.info(resource1);
expect(resource1.fetch_status).toBe(Resource.FETCH_STATUS_DONE);
}));
});

View File

@ -248,7 +248,7 @@ class Synchronizer {
reason = "remote does not exist, and local is new and has never been synced";
} else {
// Note or item was modified after having been deleted remotely
// "itemConflict" if for all the items except the notes, which are dealt with in a special way
// "itemConflict" is for all the items except the notes, which are dealt with in a special way
action = local.type_ == BaseModel.TYPE_NOTE ? "noteConflict" : "itemConflict";
reason = "remote has been deleted, but local has changes";
}
@ -440,7 +440,7 @@ class Synchronizer {
// 3. DELTA
// ------------------------------------------------------------------------
// Loop through all the remote items, find those that
// have been updated, and apply the changes to local.
// have been created or updated, and apply the changes to local.
// ------------------------------------------------------------------------
if (syncSteps.indexOf("delta") >= 0) {
@ -525,6 +525,7 @@ class Synchronizer {
this.logger().warn('Rejected by target: ' + path + ': ' + error.message);
action = null;
} else {
error.message = 'On file ' + path + ': ' + error.message;
throw error;
}
}