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

All: Fixes #600: Improved resuming of long sync operations so that it doesn't needlessly re-download the items from the beginning

This commit is contained in:
Laurent Cozic 2018-06-10 23:16:27 +01:00
parent ab9675544c
commit b6619b41df
4 changed files with 16 additions and 2 deletions

View File

@ -152,7 +152,7 @@ class SideBarComponent extends React.Component {
marginRight: 5,
minHeight: 70,
wordWrap: "break-word",
width: "100%",
//width: "100%",
},
};

View File

@ -216,7 +216,7 @@ function basicDeltaContextFromOptions_(options) {
// a built-in delta API. OneDrive and Dropbox have one for example, but Nextcloud and obviously
// the file system do not.
async function basicDelta(path, getDirStatFn, options) {
const outputLimit = 1000;
const outputLimit = 50;
const itemIds = await options.allItemIdsHandler();
if (!Array.isArray(itemIds)) throw new Error('Delta API not supported - local IDs must be provided');

View File

@ -100,6 +100,11 @@ reg.scheduleSync = async (delay = null, syncOptions = null) => {
try {
reg.logger().info("Starting scheduled sync");
const options = Object.assign({}, syncOptions, { context: context });
if (!options.saveContextHandler) {
options.saveContextHandler = (newContext) => {
Setting.setValue(contextKey, JSON.stringify(newContext));
}
}
const newContext = await sync.start(options);
Setting.setValue(contextKey, JSON.stringify(newContext));
} catch (error) {

View File

@ -570,6 +570,15 @@ class Synchronizer {
// items being synced twice as an update. If the local and remote items are identical
// the update will simply be skipped.
if (!hasCancelled) {
if (options.saveContextHandler) {
const deltaToSave = Object.assign({}, listResult.context);
// Remove these two variables because they can be large and can be rebuilt
// the next time the sync is started.
delete deltaToSave.statsCache;
delete deltaToSave.statIdsCache;
options.saveContextHandler({ delta: deltaToSave });
}
if (!listResult.hasMore) {
newDeltaContext = listResult.context;
break;