Various improvements #169
1 changed files with 31 additions and 27 deletions
Extract function
commit
aaf6088d62
|
|
@ -260,33 +260,7 @@ export class UnrestrictedSyncer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.isDeleted) {
|
if (response.isDeleted) {
|
||||||
this.history.addHistoryEntry({
|
return this.applyRemoteDeleteLocally(document, response);
|
||||||
status: SyncStatus.SUCCESS,
|
|
||||||
details: {
|
|
||||||
type: SyncType.DELETE,
|
|
||||||
relativePath: document.relativePath
|
|
||||||
},
|
|
||||||
message:
|
|
||||||
"File has been deleted remotely, so we deleted it locally",
|
|
||||||
author: response.userId,
|
|
||||||
timestamp: new Date(response.updatedDate)
|
|
||||||
});
|
|
||||||
|
|
||||||
this.database.delete(document.relativePath);
|
|
||||||
this.database.updateDocumentMetadata(
|
|
||||||
{
|
|
||||||
parentVersionId: response.vaultUpdateId,
|
|
||||||
hash: EMPTY_HASH,
|
|
||||||
remoteRelativePath: response.relativePath
|
|
||||||
},
|
|
||||||
document
|
|
||||||
);
|
|
||||||
|
|
||||||
await this.operations.delete(document.relativePath);
|
|
||||||
|
|
||||||
this.database.addSeenUpdateId(response.vaultUpdateId);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let actualPath = document.relativePath;
|
let actualPath = document.relativePath;
|
||||||
|
|
@ -577,4 +551,34 @@ export class UnrestrictedSyncer {
|
||||||
this.contentCache.put(updateId, contentBytes);
|
this.contentCache.put(updateId, contentBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async applyRemoteDeleteLocally(
|
||||||
|
document: DocumentRecord,
|
||||||
|
response: DocumentVersion | DocumentUpdateResponse
|
||||||
|
): Promise<void> {
|
||||||
|
this.history.addHistoryEntry({
|
||||||
|
status: SyncStatus.SUCCESS,
|
||||||
|
details: {
|
||||||
|
type: SyncType.DELETE,
|
||||||
|
relativePath: document.relativePath
|
||||||
|
},
|
||||||
|
message: "File has been deleted remotely, so we deleted it locally",
|
||||||
|
author: response.userId,
|
||||||
|
timestamp: new Date(response.updatedDate)
|
||||||
|
});
|
||||||
|
|
||||||
|
this.database.delete(document.relativePath);
|
||||||
|
this.database.updateDocumentMetadata(
|
||||||
|
{
|
||||||
|
parentVersionId: response.vaultUpdateId,
|
||||||
|
hash: EMPTY_HASH,
|
||||||
|
remoteRelativePath: response.relativePath
|
||||||
|
},
|
||||||
|
document
|
||||||
|
);
|
||||||
|
|
||||||
|
await this.operations.delete(document.relativePath);
|
||||||
|
|
||||||
|
this.database.addSeenUpdateId(response.vaultUpdateId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue