Use consistent vault name
This commit is contained in:
parent
8cfbaa1bda
commit
1b57e277a2
1 changed files with 21 additions and 5 deletions
|
|
@ -10,6 +10,7 @@ import type { Logger } from "../tracing/logger";
|
||||||
import type { Settings } from "../persistence/settings";
|
import type { Settings } from "../persistence/settings";
|
||||||
import type { ConnectionStatus } from "./connection-status";
|
import type { ConnectionStatus } from "./connection-status";
|
||||||
import { sleep } from "../utils/sleep";
|
import { sleep } from "../utils/sleep";
|
||||||
|
import { SyncResetError } from "./sync-reset-error";
|
||||||
|
|
||||||
export interface CheckConnectionResult {
|
export interface CheckConnectionResult {
|
||||||
isSuccessful: boolean;
|
isSuccessful: boolean;
|
||||||
|
|
@ -69,6 +70,8 @@ export class SyncService {
|
||||||
relativePath: RelativePath;
|
relativePath: RelativePath;
|
||||||
contentBytes: Uint8Array;
|
contentBytes: Uint8Array;
|
||||||
}): Promise<components["schemas"]["DocumentVersionWithoutContent"]> {
|
}): Promise<components["schemas"]["DocumentVersionWithoutContent"]> {
|
||||||
|
const vaultName = this.settings.getSettings().vaultName;
|
||||||
|
|
||||||
return this.withRetries(async () => {
|
return this.withRetries(async () => {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
if (documentId !== undefined) {
|
if (documentId !== undefined) {
|
||||||
|
|
@ -82,7 +85,7 @@ export class SyncService {
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
path: {
|
path: {
|
||||||
vault_id: this.settings.getSettings().vaultName
|
vault_id: vaultName
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
authorization: `Bearer ${this.settings.getSettings().token}`
|
authorization: `Bearer ${this.settings.getSettings().token}`
|
||||||
|
|
@ -120,6 +123,8 @@ export class SyncService {
|
||||||
relativePath: RelativePath;
|
relativePath: RelativePath;
|
||||||
contentBytes: Uint8Array;
|
contentBytes: Uint8Array;
|
||||||
}): Promise<components["schemas"]["DocumentUpdateResponse"]> {
|
}): Promise<components["schemas"]["DocumentUpdateResponse"]> {
|
||||||
|
const vaultName = this.settings.getSettings().vaultName;
|
||||||
|
|
||||||
return this.withRetries(async () => {
|
return this.withRetries(async () => {
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
`Updating document ${documentId} with parent version ${parentVersionId} and relative path ${relativePath}`
|
`Updating document ${documentId} with parent version ${parentVersionId} and relative path ${relativePath}`
|
||||||
|
|
@ -134,7 +139,7 @@ export class SyncService {
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
path: {
|
path: {
|
||||||
vault_id: this.settings.getSettings().vaultName,
|
vault_id: vaultName,
|
||||||
document_id: documentId
|
document_id: documentId
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
|
|
@ -170,12 +175,14 @@ export class SyncService {
|
||||||
relativePath: RelativePath;
|
relativePath: RelativePath;
|
||||||
}): Promise<components["schemas"]["DocumentVersionWithoutContent"]> {
|
}): Promise<components["schemas"]["DocumentVersionWithoutContent"]> {
|
||||||
return this.withRetries(async () => {
|
return this.withRetries(async () => {
|
||||||
|
const vaultName = this.settings.getSettings().vaultName;
|
||||||
|
|
||||||
const response = await this.client.DELETE(
|
const response = await this.client.DELETE(
|
||||||
"/vaults/{vault_id}/documents/{document_id}",
|
"/vaults/{vault_id}/documents/{document_id}",
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
path: {
|
path: {
|
||||||
vault_id: this.settings.getSettings().vaultName,
|
vault_id: vaultName,
|
||||||
document_id: documentId
|
document_id: documentId
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
|
|
@ -205,13 +212,15 @@ export class SyncService {
|
||||||
}: {
|
}: {
|
||||||
documentId: DocumentId;
|
documentId: DocumentId;
|
||||||
}): Promise<components["schemas"]["DocumentVersion"]> {
|
}): Promise<components["schemas"]["DocumentVersion"]> {
|
||||||
|
const vaultName = this.settings.getSettings().vaultName;
|
||||||
|
|
||||||
return this.withRetries(async () => {
|
return this.withRetries(async () => {
|
||||||
const response = await this.client.GET(
|
const response = await this.client.GET(
|
||||||
"/vaults/{vault_id}/documents/{document_id}",
|
"/vaults/{vault_id}/documents/{document_id}",
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
path: {
|
path: {
|
||||||
vault_id: this.settings.getSettings().vaultName,
|
vault_id: vaultName,
|
||||||
document_id: documentId
|
document_id: documentId
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
|
|
@ -239,12 +248,14 @@ export class SyncService {
|
||||||
since?: VaultUpdateId
|
since?: VaultUpdateId
|
||||||
): Promise<components["schemas"]["FetchLatestDocumentsResponse"]> {
|
): Promise<components["schemas"]["FetchLatestDocumentsResponse"]> {
|
||||||
return this.withRetries(async () => {
|
return this.withRetries(async () => {
|
||||||
|
const vaultName = this.settings.getSettings().vaultName;
|
||||||
|
|
||||||
const response = await this.client.GET(
|
const response = await this.client.GET(
|
||||||
"/vaults/{vault_id}/documents",
|
"/vaults/{vault_id}/documents",
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
path: {
|
path: {
|
||||||
vault_id: this.settings.getSettings().vaultName
|
vault_id: vaultName
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
authorization: `Bearer ${this.settings.getSettings().token}`
|
authorization: `Bearer ${this.settings.getSettings().token}`
|
||||||
|
|
@ -339,6 +350,11 @@ export class SyncService {
|
||||||
try {
|
try {
|
||||||
return await fn();
|
return await fn();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
// We must not retry errors coming from reset
|
||||||
|
if (e instanceof SyncResetError) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
this.logger.error(`Failed network call (${e}), retrying`);
|
this.logger.error(`Failed network call (${e}), retrying`);
|
||||||
await sleep(1000);
|
await sleep(1000);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue