fix(android): the ETag dies with the plaintext it describes
Unlock, lock, download again: the app sent If-None-Match, got 304, and had nothing to show - on Windows there is no local cache to fall back on, so the only way back in was restarting. FETag outlived the vault it belonged to; LockVault now clears it. The 304 branch also stopped re-reading the cache file (which can fail on an expired authentication) and serves the plaintext it already holds - in memory, or the copy read at the start of the call. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+36
-6
@@ -499,6 +499,12 @@ procedure TForm8.LockVault;
|
|||||||
begin
|
begin
|
||||||
// Le clair dispararait de la memoire ET de l'ecran. Le fichier local reste :
|
// Le clair dispararait de la memoire ET de l'ecran. Le fichier local reste :
|
||||||
// il est chiffre par le materiel, c'est tout l'interet du cache.
|
// il est chiffre par le materiel, c'est tout l'interet du cache.
|
||||||
|
//
|
||||||
|
// L'ETAG PART AVEC LUI. Il decrit le clair detenu, pas un telechargement :
|
||||||
|
// le garder ferait repondre 304 au serveur alors qu'on n'a plus rien a
|
||||||
|
// afficher - et sur un poste sans cache local (hors Android), plus aucun
|
||||||
|
// moyen de rouvrir le coffre sans relancer l'application.
|
||||||
|
FETag := '';
|
||||||
FVault.Clear;
|
FVault.Clear;
|
||||||
FList.Clear;
|
FList.Clear;
|
||||||
FCurrent := Default(TVaultEntry);
|
FCurrent := Default(TVaultEntry);
|
||||||
@@ -628,12 +634,36 @@ begin
|
|||||||
begin
|
begin
|
||||||
// C'est ICI que le cache paie : pas de telechargement, pas de
|
// C'est ICI que le cache paie : pas de telechargement, pas de
|
||||||
// derivation, le coffre vient du fichier local.
|
// derivation, le coffre vient du fichier local.
|
||||||
Log(' 304 : inchange, coffre servi depuis le cache');
|
// Rien n'a change cote serveur : le clair est deja quelque part,
|
||||||
// SetBusy AVANT l'ouverture : la file est FIFO, et celui du
|
// soit en memoire, soit dans le cache lu en debut de procedure.
|
||||||
// bloc finally passerait apres - DoOpenLocal sortirait aussitot
|
// Surtout PAS de relecture du fichier ici - elle peut echouer
|
||||||
// sur son garde-fou "occupe".
|
// (authentification expiree) et laisserait l'utilisateur sans
|
||||||
TThread.Queue(nil, procedure
|
// rien apres un appel pourtant reussi.
|
||||||
begin SetBusy(False); DoOpenLocal(nil); end);
|
TThread.Queue(nil,
|
||||||
|
procedure
|
||||||
|
begin
|
||||||
|
if FVault.Count > 0 then
|
||||||
|
begin
|
||||||
|
Log(' 304 : inchange, coffre deja ouvert');
|
||||||
|
ShowList;
|
||||||
|
end
|
||||||
|
else if LCached <> '' then
|
||||||
|
begin
|
||||||
|
Log(' 304 : inchange, coffre servi depuis le cache');
|
||||||
|
try
|
||||||
|
AdoptVault(LCached);
|
||||||
|
except
|
||||||
|
on E: Exception do Status('Cache illisible : ' + E.Message);
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
// Un ETag sans clair correspondant : l'invariant est rompu.
|
||||||
|
// On le jette pour que l'appel suivant retelecharge.
|
||||||
|
FETag := '';
|
||||||
|
Status('Cache absent - appuyer a nouveau pour telecharger');
|
||||||
|
end;
|
||||||
|
end);
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
ssNoSnapshot:
|
ssNoSnapshot:
|
||||||
|
|||||||
Reference in New Issue
Block a user