Differential updates
This commit is contained in:
parent
c11e9350d5
commit
f58d1332c4
12 changed files with 873 additions and 153 deletions
53
ts/scripts/generate-fixtures.ts
Normal file
53
ts/scripts/generate-fixtures.ts
Normal file
|
@ -0,0 +1,53 @@
|
|||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import fs from 'fs/promises';
|
||||
import path from 'path';
|
||||
import crypto from 'crypto';
|
||||
import { execFileSync } from 'child_process';
|
||||
|
||||
const FIXTURES = path.join(__dirname, '..', '..', 'fixtures');
|
||||
const SIZE = 256 * 1024;
|
||||
|
||||
async function main() {
|
||||
const original = crypto.randomBytes(SIZE);
|
||||
|
||||
const originalPath = path.join(FIXTURES, 'diff-original.bin');
|
||||
await fs.writeFile(originalPath, original);
|
||||
|
||||
// Add a broken byte to help create useful blockmaps
|
||||
original[Math.floor(Math.random() * original.length)] = 0;
|
||||
|
||||
const modifiedPath = path.join(FIXTURES, 'diff-modified.bin');
|
||||
await fs.writeFile(modifiedPath, original);
|
||||
|
||||
const appBuilder = path.join(
|
||||
__dirname,
|
||||
'..',
|
||||
'..',
|
||||
'node_modules',
|
||||
'app-builder-bin',
|
||||
'mac',
|
||||
'app-builder_amd64'
|
||||
);
|
||||
|
||||
for (const filePath of [originalPath, modifiedPath]) {
|
||||
console.log('Adding blockmap to', filePath);
|
||||
|
||||
// Put blockmap into a separate file
|
||||
console.log(
|
||||
execFileSync(appBuilder, [
|
||||
'blockmap',
|
||||
'--input',
|
||||
filePath,
|
||||
'--output',
|
||||
`${filePath}.blockmap`,
|
||||
]).toString()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
main().catch(err => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue