Clean up diff
This commit is contained in:
parent
8d695999c6
commit
10568efebe
6 changed files with 25 additions and 57 deletions
|
|
@ -23,7 +23,6 @@ pub type Transaction<'a> = sqlx::Transaction<'a, Sqlite>;
|
|||
|
||||
impl Database {
|
||||
pub async fn try_new(config: &DatabaseConfig) -> Result<Self> {
|
||||
// Create the databases directory if it doesn't exist
|
||||
tokio::fs::create_dir_all(&config.databases_directory_path)
|
||||
.await
|
||||
.with_context(|| {
|
||||
|
|
@ -67,7 +66,6 @@ impl Database {
|
|||
.databases_directory_path
|
||||
.join(format!("{vault}.sqlite"));
|
||||
|
||||
// Continue with database connection setup
|
||||
let connection_options = SqliteConnectOptions::new()
|
||||
.filename(file_name.clone())
|
||||
.create_if_missing(true)
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ export class FileOperations {
|
|||
currentText = currentText.replace(/\r\n/g, "\n");
|
||||
if (currentText !== expectedText) {
|
||||
this.logger.debug(
|
||||
`Performing a 3-way merge for ${path} with the expected content:\n${expectedText}`
|
||||
`Performing a 3-way merge for ${path} with the expected content`
|
||||
);
|
||||
|
||||
return mergeText(expectedText, currentText, newText);
|
||||
|
|
|
|||
|
|
@ -452,7 +452,10 @@ export interface components {
|
|||
Array_of_uint8: number[];
|
||||
CreateDocumentVersion: {
|
||||
contentBase64: string;
|
||||
/** Format: uuid */
|
||||
/**
|
||||
* Format: uuid
|
||||
* @description The client can decide the document id (if it wishes to) in order to help with syncing. If the client does not provide a document id, the server will generate one. If the client provides a document id it must not already exist in the database.
|
||||
*/
|
||||
documentId?: string | null;
|
||||
relativePath: string;
|
||||
};
|
||||
|
|
@ -476,7 +479,6 @@ export interface components {
|
|||
type: "FastForwardUpdate";
|
||||
/** Format: date-time */
|
||||
updatedDate: string;
|
||||
vaultId: string;
|
||||
/** Format: int64 */
|
||||
vaultUpdateId: number;
|
||||
}
|
||||
|
|
@ -490,7 +492,6 @@ export interface components {
|
|||
type: "MergingUpdate";
|
||||
/** Format: date-time */
|
||||
updatedDate: string;
|
||||
vaultId: string;
|
||||
/** Format: int64 */
|
||||
vaultUpdateId: number;
|
||||
};
|
||||
|
|
@ -502,7 +503,6 @@ export interface components {
|
|||
relativePath: string;
|
||||
/** Format: date-time */
|
||||
updatedDate: string;
|
||||
vaultId: string;
|
||||
/** Format: int64 */
|
||||
vaultUpdateId: number;
|
||||
};
|
||||
|
|
@ -513,7 +513,6 @@ export interface components {
|
|||
relativePath: string;
|
||||
/** Format: date-time */
|
||||
updatedDate: string;
|
||||
vaultId: string;
|
||||
/** Format: int64 */
|
||||
vaultUpdateId: number;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -60,24 +60,6 @@ export class Syncer {
|
|||
);
|
||||
}
|
||||
|
||||
private static async forgivingFileNotFoundWrapper<T>(
|
||||
fn: () => Promise<T>,
|
||||
logger: Logger
|
||||
): Promise<T | undefined> {
|
||||
try {
|
||||
return await fn();
|
||||
} catch (e) {
|
||||
if (e instanceof FileNotFoundError) {
|
||||
logger.debug(
|
||||
`File has been deleted or moved before we had a chance to inspect it, skipping`
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public addRemainingOperationsListener(
|
||||
listener: (remainingOperations: number) => void
|
||||
): void {
|
||||
|
|
@ -355,13 +337,7 @@ export class Syncer {
|
|||
// Perhaps the file has been moved; let's check by looking at the deleted files
|
||||
const contentHash = await this.syncQueue.add(async () => {
|
||||
const contentBytes =
|
||||
await Syncer.forgivingFileNotFoundWrapper(
|
||||
async () => this.operations.read(relativePath),
|
||||
this.logger
|
||||
);
|
||||
if (contentBytes === undefined) {
|
||||
return;
|
||||
}
|
||||
await this.operations.read(relativePath); // this can throw FileNotFoundError
|
||||
return hash(contentBytes);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -251,10 +251,7 @@ export class MockAgent extends MockClient {
|
|||
`Decided to create file ${file} with content ${content}`
|
||||
);
|
||||
|
||||
return this.create(
|
||||
file,
|
||||
new TextEncoder().encode(` |${content}| `)
|
||||
);
|
||||
return this.create(file, new TextEncoder().encode(` ${content} `));
|
||||
}
|
||||
|
||||
private async changeFetchChangesUpdateIntervalMsAction(): Promise<void> {
|
||||
|
|
@ -328,7 +325,7 @@ export class MockAgent extends MockClient {
|
|||
`Decided to update file ${file} with ${content}`
|
||||
);
|
||||
this.doNotTouchWhileOffline.push(file);
|
||||
await this.atomicUpdateText(file, (old) => old + ` |${content}| `);
|
||||
await this.atomicUpdateText(file, (old) => old + ` ${content} `);
|
||||
}
|
||||
|
||||
private async deleteFileAction(files: RelativePath[]): Promise<void> {
|
||||
|
|
|
|||
|
|
@ -46,10 +46,6 @@ async function runTest({
|
|||
);
|
||||
}
|
||||
|
||||
// for debugging
|
||||
// eslint-disable-next-line
|
||||
(globalThis as any).clients = clients;
|
||||
|
||||
try {
|
||||
await Promise.all(clients.map(async (client) => client.init()));
|
||||
|
||||
|
|
@ -109,20 +105,22 @@ async function runTest({
|
|||
}
|
||||
|
||||
async function runTests(): Promise<void> {
|
||||
for (const concurrency of [
|
||||
16,
|
||||
1 // test with concurrency 1 to check for deadlocks
|
||||
]) {
|
||||
for (const doDeletes of [true, false]) {
|
||||
for (const useSlowFileEvents of [true, false]) {
|
||||
await runTest({
|
||||
agentCount: 4,
|
||||
concurrency,
|
||||
iterations: 200,
|
||||
doDeletes,
|
||||
useSlowFileEvents,
|
||||
jitterScaleInSeconds: 0.75
|
||||
});
|
||||
for (const useSlowFileEvents of [false, true]) {
|
||||
for (const concurrency of [
|
||||
16,
|
||||
1 // test with concurrency 1 to check for deadlocks
|
||||
]) {
|
||||
for (const doDeletes of [true, false]) {
|
||||
for (let i = 0; i < 4; i++) {
|
||||
await runTest({
|
||||
agentCount: 2,
|
||||
concurrency,
|
||||
iterations: 200,
|
||||
doDeletes,
|
||||
useSlowFileEvents,
|
||||
jitterScaleInSeconds: 0.75
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -148,7 +146,7 @@ runTests()
|
|||
.then(() => {
|
||||
process.exit(0);
|
||||
})
|
||||
.catch(async (err: unknown) => {
|
||||
.catch((err: unknown) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue