Various improvements #169
3 changed files with 11 additions and 9 deletions
Small clean up
commit
2ac5060315
|
|
@ -198,6 +198,9 @@ export class Database {
|
||||||
relativePath: RelativePath,
|
relativePath: RelativePath,
|
||||||
promise: Promise<unknown>
|
promise: Promise<unknown>
|
||||||
): DocumentRecord {
|
): DocumentRecord {
|
||||||
|
this.logger.debug(
|
||||||
|
`Creating new pending document: ${relativePath} (${documentId})`
|
||||||
|
);
|
||||||
const previousEntry =
|
const previousEntry =
|
||||||
this.getLatestDocumentByRelativePath(relativePath);
|
this.getLatestDocumentByRelativePath(relativePath);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -282,13 +282,10 @@ export class WebSocketManager {
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
`Received cursor positions for ${JSON.stringify(message.clients)}`
|
`Received cursor positions for ${JSON.stringify(message.clients)}`
|
||||||
);
|
);
|
||||||
const filteredClients = message.clients.filter(
|
|
||||||
(client) => client.deviceId !== this.deviceId
|
|
||||||
);
|
|
||||||
|
|
||||||
await awaitAll(
|
await awaitAll(
|
||||||
this.remoteCursorsUpdateListeners.map(async (listener) => {
|
this.remoteCursorsUpdateListeners.map(async (listener) => {
|
||||||
await listener(filteredClients).catch((error: unknown) => {
|
await listener(message.clients).catch((error: unknown) => {
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
`Error in cursor positions listener: ${String(error)}`
|
`Error in cursor positions listener: ${String(error)}`
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -69,19 +69,18 @@ export class UnrestrictedSyncer {
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.executeSync(updateDetails, async () => {
|
return this.executeSync(updateDetails, async () => {
|
||||||
|
const originalRelativePath = document.relativePath;
|
||||||
if (document.isDeleted) {
|
if (document.isDeleted) {
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
`Document ${document.relativePath} has been already deleted, no need to create it`
|
`Document ${originalRelativePath} has been already deleted, no need to create it`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const contentBytes = await this.operations.read(
|
const contentBytes =
|
||||||
document.relativePath
|
await this.operations.read(originalRelativePath); // this can throw FileNotFoundError
|
||||||
); // this can throw FileNotFoundError
|
|
||||||
const contentHash = hash(contentBytes);
|
const contentHash = hash(contentBytes);
|
||||||
|
|
||||||
const originalRelativePath = document.relativePath;
|
|
||||||
const response = await this.syncService.create({
|
const response = await this.syncService.create({
|
||||||
documentId: document.documentId,
|
documentId: document.documentId,
|
||||||
relativePath: originalRelativePath,
|
relativePath: originalRelativePath,
|
||||||
|
|
@ -99,6 +98,9 @@ export class UnrestrictedSyncer {
|
||||||
|
|
||||||
// In case a document with the same name (but different ID) had existed remotely that we haven't known about
|
// In case a document with the same name (but different ID) had existed remotely that we haven't known about
|
||||||
if (response.relativePath != originalRelativePath) {
|
if (response.relativePath != originalRelativePath) {
|
||||||
|
this.logger.debug(
|
||||||
|
`Document ${originalRelativePath} has been created remotely at a different path: ${response.relativePath}, moving it locally`
|
||||||
|
);
|
||||||
await this.operations.move(
|
await this.operations.move(
|
||||||
document.relativePath,
|
document.relativePath,
|
||||||
response.relativePath
|
response.relativePath
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue