Clean up
This commit is contained in:
parent
bb2ff23a4a
commit
61e4f43131
3 changed files with 16 additions and 14 deletions
2
.github/workflows/publish-docker.yml
vendored
2
.github/workflows/publish-docker.yml
vendored
|
|
@ -17,7 +17,7 @@ env:
|
|||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
build-docker:
|
||||
publish-docker:
|
||||
runs-on: self-hosted
|
||||
|
||||
permissions:
|
||||
|
|
|
|||
|
|
@ -21,6 +21,12 @@ export interface StoredDatabase {
|
|||
lastSeenUpdateId: VaultUpdateId | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a document in the database.
|
||||
*
|
||||
* It is mutable and its content should always represent the latest
|
||||
* state of the document on disk based on the update events we have seen.
|
||||
*/
|
||||
export interface DocumentRecord {
|
||||
relativePath: RelativePath;
|
||||
documentId: DocumentId;
|
||||
|
|
@ -114,11 +120,8 @@ export class Database {
|
|||
this.save();
|
||||
}
|
||||
|
||||
public setDocument(
|
||||
{
|
||||
parentVersionId,
|
||||
hash
|
||||
}: {
|
||||
public updateDocumentMetadata(
|
||||
metadata: {
|
||||
parentVersionId: VaultUpdateId;
|
||||
hash: string;
|
||||
},
|
||||
|
|
@ -128,10 +131,9 @@ export class Database {
|
|||
throw new Error("Document not found in database");
|
||||
}
|
||||
|
||||
toUpdate.metadata = { parentVersionId, hash };
|
||||
toUpdate.metadata = metadata;
|
||||
|
||||
this.save();
|
||||
return;
|
||||
}
|
||||
|
||||
public removeDocumentPromise(promise: Promise<void>): void {
|
||||
|
|
@ -225,7 +227,7 @@ export class Database {
|
|||
|
||||
const newDocument =
|
||||
this.getLatestDocumentByRelativePath(newRelativePath);
|
||||
if (newDocument !== undefined && !newDocument.isDeleted) {
|
||||
if (newDocument?.isDeleted === false) {
|
||||
throw new Error(
|
||||
`Document already exists at new location: ${newRelativePath}`
|
||||
);
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ export class UnrestrictedSyncer {
|
|||
type: SyncType.CREATE
|
||||
});
|
||||
|
||||
this.database.setDocument(
|
||||
this.database.updateDocumentMetadata(
|
||||
{
|
||||
parentVersionId: response.vaultUpdateId,
|
||||
hash: contentHash
|
||||
|
|
@ -92,7 +92,7 @@ export class UnrestrictedSyncer {
|
|||
type: SyncType.DELETE
|
||||
});
|
||||
|
||||
this.database.setDocument(
|
||||
this.database.updateDocumentMetadata(
|
||||
{
|
||||
parentVersionId: response.vaultUpdateId,
|
||||
hash: EMPTY_HASH
|
||||
|
|
@ -190,7 +190,7 @@ export class UnrestrictedSyncer {
|
|||
});
|
||||
|
||||
this.database.delete(document.relativePath);
|
||||
this.database.setDocument(
|
||||
this.database.updateDocumentMetadata(
|
||||
{
|
||||
parentVersionId: response.vaultUpdateId,
|
||||
hash: EMPTY_HASH
|
||||
|
|
@ -215,7 +215,7 @@ export class UnrestrictedSyncer {
|
|||
); // this can throw FileNotFoundError
|
||||
}
|
||||
|
||||
this.database.setDocument(
|
||||
this.database.updateDocumentMetadata(
|
||||
{
|
||||
parentVersionId: response.vaultUpdateId,
|
||||
hash: contentHash
|
||||
|
|
@ -315,7 +315,7 @@ export class UnrestrictedSyncer {
|
|||
);
|
||||
|
||||
const [promise, resolve] = createPromise();
|
||||
this.database.setDocument(
|
||||
this.database.updateDocumentMetadata(
|
||||
{
|
||||
parentVersionId: remoteVersion.vaultUpdateId,
|
||||
hash: hash(contentBytes)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue