[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: sync: handle HTTP 304 correct
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: sync: handle HTTP 304 correctly |
Date: |
Wed, 23 Jun 2021 13:06:37 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new 3603a686 sync: handle HTTP 304 correctly
3603a686 is described below
commit 3603a6866977600e9cb16f5e94488fde9cfb02a5
Author: Florian Dold <florian@dold.me>
AuthorDate: Wed Jun 23 13:06:32 2021 +0200
sync: handle HTTP 304 correctly
---
packages/taler-wallet-core/src/db.ts | 9 ++++++++-
.../src/operations/backup/index.ts | 23 ++++++++++++++++++----
2 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/packages/taler-wallet-core/src/db.ts
b/packages/taler-wallet-core/src/db.ts
index 36b4e086..e640e7f2 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -1586,7 +1586,14 @@ export interface BackupProviderRecord {
*/
lastBackupHash?: string;
- lastBackupTimestamp?: Timestamp;
+ /**
+ * Last time that we successfully uploaded a backup (or
+ * the uploaded backup was already current).
+ *
+ * Does NOT correspond to the timestamp of the backup,
+ * which only changes when the backup content changes.
+ */
+ lastBackupCycleTimestamp?: Timestamp;
/**
* Proposal that we're currently trying to pay for.
diff --git a/packages/taler-wallet-core/src/operations/backup/index.ts
b/packages/taler-wallet-core/src/operations/backup/index.ts
index 0d3cf578..d367cf66 100644
--- a/packages/taler-wallet-core/src/operations/backup/index.ts
+++ b/packages/taler-wallet-core/src/operations/backup/index.ts
@@ -296,6 +296,21 @@ async function runBackupCycleForProvider(
logger.trace(`sync response status: ${resp.status}`);
+ if (resp.status === HttpResponseStatus.NotModified) {
+ await ws.db
+ .mktx((x) => ({ backupProvider: x.backupProviders }))
+ .runReadWrite(async (tx) => {
+ const prov = await tx.backupProvider.get(provider.baseUrl);
+ if (!prov) {
+ return;
+ }
+ delete prov.lastError;
+ prov.lastBackupCycleTimestamp = getTimestampNow();
+ await tx.backupProvider.put(prov);
+ });
+ return;
+ }
+
if (resp.status === HttpResponseStatus.PaymentRequired) {
logger.trace("payment required for backup");
logger.trace(`headers: ${j2s(resp.headers)}`);
@@ -360,7 +375,7 @@ async function runBackupCycleForProvider(
return;
}
prov.lastBackupHash = encodeCrock(currentBackupHash);
- prov.lastBackupTimestamp = getTimestampNow();
+ prov.lastBackupCycleTimestamp = getTimestampNow();
prov.lastError = undefined;
await tx.backupProviders.put(prov);
});
@@ -382,7 +397,7 @@ async function runBackupCycleForProvider(
return;
}
prov.lastBackupHash = encodeCrock(hash(backupEnc));
- prov.lastBackupTimestamp = getTimestampNow();
+ prov.lastBackupCycleTimestamp = getTimestampNow();
prov.lastError = undefined;
await tx.backupProvider.put(prov);
});
@@ -684,7 +699,7 @@ export async function getBackupInfo(
providers.push({
active: x.active,
syncProviderBaseUrl: x.baseUrl,
- lastSuccessfulBackupTimestamp: x.lastBackupTimestamp,
+ lastSuccessfulBackupTimestamp: x.lastBackupCycleTimestamp,
paymentProposalIds: x.paymentProposalIds,
lastError: x.lastError,
paymentStatus: await getProviderPaymentInfo(ws, x),
@@ -759,7 +774,7 @@ async function backupRecoveryTheirs(
}
const providers = await tx.backupProviders.iter().toArray();
for (const prov of providers) {
- prov.lastBackupTimestamp = undefined;
+ prov.lastBackupCycleTimestamp = undefined;
prov.lastBackupHash = undefined;
await tx.backupProviders.put(prov);
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: sync: handle HTTP 304 correctly,
gnunet <=