1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

All: Improved sync when dealing with many items, in particular when using Nextcloud

This commit is contained in:
Laurent Cozic
2018-03-09 19:07:38 +00:00
parent c4f19465a6
commit 4df5f668dc
7 changed files with 392 additions and 338 deletions

View File

@@ -43,8 +43,9 @@ reg.syncTarget = (syncTargetId = null) => {
return target;
};
reg.scheduleSync = async (delay = null) => {
reg.scheduleSync = async (delay = null, syncOptions = null) => {
if (delay === null) delay = 1000 * 10;
if (syncOptions === null) syncOptions = {};
let promiseResolve = null;
const promise = new Promise((resolve, reject) => {
@@ -58,10 +59,10 @@ reg.scheduleSync = async (delay = null) => {
reg.logger().info("Scheduling sync operation...");
if (Setting.value("env") === "dev" && delay !== 0) {
reg.logger().info("Schedule sync DISABLED!!!");
return;
}
// if (Setting.value("env") === "dev" && delay !== 0) {
// reg.logger().info("Schedule sync DISABLED!!!");
// return;
// }
const timeoutCallback = async () => {
reg.scheduleSyncId_ = null;
@@ -93,7 +94,8 @@ reg.scheduleSync = async (delay = null) => {
try {
reg.logger().info("Starting scheduled sync");
let newContext = await sync.start({ context: context });
const options = Object.assign({}, syncOptions, { context: context });
const newContext = await sync.start(options);
Setting.setValue(contextKey, JSON.stringify(newContext));
} catch (error) {
if (error.code == "alreadyStarted") {