WIP: Migrate to using taskfile #187
10 changed files with 92 additions and 98 deletions
Lint
commit
e3a90833ff
|
|
@ -74,7 +74,6 @@ export class Database {
|
|||
this.documents.forEach((doc) => {
|
||||
this.lastSeenUpdateIds.add(doc.metadata?.parentVersionId);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public get length(): number {
|
||||
|
|
@ -282,7 +281,6 @@ export class Database {
|
|||
candidate.isDeleted = true;
|
||||
}
|
||||
|
||||
|
||||
public getLastSeenUpdateId(): VaultUpdateId {
|
||||
return this.lastSeenUpdateIds.min;
|
||||
}
|
||||
|
|
@ -317,7 +315,7 @@ export class Database {
|
|||
...metadata! // `resolvedDocuments` only returns docs with metadata set
|
||||
})
|
||||
),
|
||||
lastSeenUpdateId: this.lastSeenUpdateIds.min,
|
||||
lastSeenUpdateId: this.lastSeenUpdateIds.min
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -157,7 +157,8 @@ export class SyncService {
|
|||
(await response.json()) as DocumentUpdateResponse; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
|
||||
|
||||
this.logger.debug(
|
||||
`Updated document ${JSON.stringify(result)} with id ${result.documentId
|
||||
`Updated document ${JSON.stringify(result)} with id ${
|
||||
result.documentId
|
||||
}}`
|
||||
);
|
||||
|
||||
|
|
@ -209,7 +210,8 @@ export class SyncService {
|
|||
(await response.json()) as DocumentUpdateResponse; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion
|
||||
|
||||
this.logger.debug(
|
||||
`Updated document ${JSON.stringify(result)} with id ${result.documentId
|
||||
`Updated document ${JSON.stringify(result)} with id ${
|
||||
result.documentId
|
||||
}}`
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -260,10 +260,9 @@ export class WebSocketManager {
|
|||
this.resolveDisconnectingPromise?.();
|
||||
this.resolveDisconnectingPromise = null;
|
||||
} else {
|
||||
const delay = this.settings.getSettings().webSocketRetryIntervalMs;
|
||||
this.logger.info(
|
||||
`Reconnecting to WebSocket in ${delay}ms...`
|
||||
);
|
||||
const delay =
|
||||
this.settings.getSettings().webSocketRetryIntervalMs;
|
||||
this.logger.info(`Reconnecting to WebSocket in ${delay}ms...`);
|
||||
this.reconnectTimeoutId = setTimeout(() => {
|
||||
this.reconnectTimeoutId = undefined;
|
||||
this.initializeWebSocket();
|
||||
|
|
|
|||
|
|
@ -484,6 +484,5 @@ export class Syncer {
|
|||
return this.syncLocallyDeletedFile(relativePath);
|
||||
})
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ export class UnrestrictedSyncer {
|
|||
forceMerge: true
|
||||
});
|
||||
|
||||
this.handleMaybeMergingResponse({
|
||||
await this.handleMaybeMergingResponse({
|
||||
document,
|
||||
response,
|
||||
contentHash,
|
||||
|
|
@ -181,7 +181,7 @@ export class UnrestrictedSyncer {
|
|||
const contentBytes = await this.operations.read(
|
||||
document.relativePath
|
||||
); // this can throw FileNotFoundError
|
||||
let contentHash = hash(contentBytes);
|
||||
const contentHash = hash(contentBytes);
|
||||
|
||||
const areThereLocalChanges = !(
|
||||
document.metadata.hash === contentHash && oldPath === undefined
|
||||
|
|
@ -234,10 +234,9 @@ export class UnrestrictedSyncer {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
this.handleMaybeMergingResponse({
|
||||
await this.handleMaybeMergingResponse({
|
||||
document,
|
||||
response: response!,
|
||||
response: response,
|
||||
contentHash,
|
||||
originalRelativePath,
|
||||
originalContentBytes: contentBytes
|
||||
|
|
@ -288,7 +287,8 @@ export class UnrestrictedSyncer {
|
|||
type: SyncType.DELETE,
|
||||
relativePath: document.relativePath
|
||||
},
|
||||
message: "File has been deleted remotely, so we deleted it locally",
|
||||
message:
|
||||
"File has been deleted remotely, so we deleted it locally",
|
||||
author: response.userId,
|
||||
timestamp: new Date(response.updatedDate)
|
||||
});
|
||||
|
|
@ -460,8 +460,7 @@ export class UnrestrictedSyncer {
|
|||
}
|
||||
}
|
||||
|
||||
private async handleMaybeMergingResponse(
|
||||
{
|
||||
private async handleMaybeMergingResponse({
|
||||
document,
|
||||
response,
|
||||
contentHash,
|
||||
|
|
@ -469,15 +468,13 @@ export class UnrestrictedSyncer {
|
|||
originalContentBytes
|
||||
}: {
|
||||
document: DocumentRecord;
|
||||
response: DocumentVersion | DocumentUpdateResponse,
|
||||
contentHash: string,
|
||||
originalRelativePath: string,
|
||||
originalContentBytes: Uint8Array
|
||||
}
|
||||
): Promise<void> {
|
||||
|
||||
response: DocumentVersion | DocumentUpdateResponse;
|
||||
contentHash: string;
|
||||
originalRelativePath: string;
|
||||
originalContentBytes: Uint8Array;
|
||||
}): Promise<void> {
|
||||
// `document` is mutable and reflects the latest state in the local database
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
|
||||
if (document.isDeleted) {
|
||||
this.logger.info(
|
||||
`Document ${document.relativePath} has been deleted before we could finish updating it`
|
||||
|
|
@ -572,7 +569,8 @@ export class UnrestrictedSyncer {
|
|||
type: SyncType.SKIPPED,
|
||||
relativePath
|
||||
},
|
||||
message: `File size of ${sizeInMB} MB exceeds the maximum file size limit of ${maxFileSizeMB
|
||||
message: `File size of ${sizeInMB} MB exceeds the maximum file size limit of ${
|
||||
maxFileSizeMB
|
||||
} MB`
|
||||
};
|
||||
}
|
||||
|
|
@ -598,8 +596,6 @@ export class UnrestrictedSyncer {
|
|||
document: DocumentRecord,
|
||||
response: DocumentVersion | DocumentUpdateResponse
|
||||
): Promise<void> {
|
||||
|
||||
|
||||
this.database.delete(document.relativePath);
|
||||
this.database.updateDocumentMetadata(
|
||||
{
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ pub async fn merge_with_stored_version(
|
|||
};
|
||||
|
||||
// We can only update the relative path if we're the first one to do so
|
||||
let new_relative_path = if parent_document_path == &latest_version.relative_path
|
||||
let new_relative_path = if parent_document_path == latest_version.relative_path
|
||||
&& latest_version.relative_path != sanitized_relative_path
|
||||
{
|
||||
let new_path = find_first_available_path(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::app_state::database::models::VaultId;
|
||||
use crate::{app_state::database::Transaction, utils::dedup_paths::dedup_paths};
|
||||
use anyhow::Result;
|
||||
use log::{debug, info};
|
||||
use log::info;
|
||||
|
||||
pub async fn find_first_available_path(
|
||||
vault_id: &VaultId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue