1
>
/*---------------------------------------------------------------------------------------------
globalStateMerge.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { IStringDictionary } from '../../../base/common/collections.js';
7
>
import * as objects from '../../../base/common/objects.js';
8
>
import { ILogService } from '../../log/common/log.js';
9
>
import { IStorageValue, SYNC_SERVICE_URL_TYPE } from './userDataSync.js';
10
>
11
>
export interface IMergeResult {
12
>
local: { added: IStringDictionary<IStorageValue>; removed: string[]; updated: IStringDictionary<IStorageValue> };
13
>
remote: { added: string[]; removed: string[]; updated: string[]; all: IStringDictionary<IStorageValue> | null };
14
>
}
15
>
16
>
export function merge(localStorage: IStringDictionary<IStorageValue>, remoteStorage: IStringDictionary<IStorageValue> | null, baseStorage: IStringDictionary<IStorageValue> | null, storageKeys: { machine: ReadonlyArray<string>; unregistered: ReadonlyArray<string> }, logService: ILogService): IMergeResult {
17
if (!remoteStorage) {
18
return { remote: { added: Object.keys(localStorage), removed: [], updated: [], all: Object.keys(localStorage).length > 0 ? localStorage : null }, local: { added: {}, removed: [], updated: {} } };