This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 974
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync: Resend pending records periodically
Fix brave/sync#144 Also fixes some imported bookmarks lost until restart. See also: brave/sync#112 Test Plan: 1. Pyramid 0: Open and enable Sync. 2. Pyramid 1: Open and join Pyramid 0's Sync profile. Close browser. 3. P_0: Import 1000s of bookmarks. 4. P_0: Wait for Sync uploads to finish (console shows "got 0 decrypted records in BOOKMARKS after {timestamp}"). Wait an additional 3 minutes. 6. P_0: Export bookmarks to HTML file. 7. P_1: Open and wait for Sync download (~1m). 8. P_1: Export bookmarks to HTML file. 9. Run `wc -l {P_0 bookmarks HTML}` and `wc -l {P_0 bookmarks HTML}` and compare. These should match.
- Loading branch information
Showing
6 changed files
with
74 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
'use strict' | ||
|
||
const JSON_POINTER_ESCAPE_CODES = { | ||
'~0': '~', | ||
'~1': '/' | ||
} | ||
|
||
const JSON_POINTER_REGEX = new RegExp(Object.keys(JSON_POINTER_ESCAPE_CODES).join('|'), 'gi') | ||
|
||
/** | ||
* Unescape a JSON pointer path part. (i.e. ~ | ||
* https://stackoverflow.com/questions/31483170/purpose-of-tilde-in-json-pointer | ||
* @param {string} string JSON pointer part. | ||
* @returns {string} | ||
*/ | ||
module.exports.unescapeJSONPointer = (string) => { | ||
return string.replace(JSON_POINTER_REGEX, (match) => { | ||
return JSON_POINTER_ESCAPE_CODES[match] | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* global describe, it */ | ||
const jsonUtil = require('../../../../../app/common/lib/jsonUtil') | ||
const assert = require('assert') | ||
|
||
require('../../../braveUnit') | ||
|
||
describe('jsonUtil test', function () { | ||
describe('unescapeJSONPointer', function () { | ||
it('Unescapes ~1 and ~0', function () { | ||
const input = 'http:~1~1people.ischool.berkeley.edu~1~0nick~1signal-protocol-js~1|0|3' | ||
const expected = 'http://people.ischool.berkeley.edu/~nick/signal-protocol-js/|0|3' | ||
const result = jsonUtil.unescapeJSONPointer(input) | ||
assert.equal(result, expected) | ||
}) | ||
|
||
it('Can do nothing', function () { | ||
const input = 'tomato' | ||
const expected = 'tomato' | ||
const result = jsonUtil.unescapeJSONPointer(input) | ||
assert.equal(result, expected) | ||
}) | ||
}) | ||
}) |