mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
Rework git askpass cache
This commit is contained in:
parent
8e5550c61d
commit
6e64cdb96e
2 changed files with 17 additions and 4 deletions
|
@ -74,4 +74,8 @@ public interface SecretQuery {
|
|||
boolean cache();
|
||||
|
||||
boolean retryOnFail();
|
||||
|
||||
default boolean respectDontCacheSetting() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ public class SecretQueryProgress {
|
|||
}
|
||||
|
||||
var firstSeenIndex = seenPrompts.indexOf(prompt);
|
||||
var ref = new SecretReference(storeId, firstSeenIndex);
|
||||
|
||||
if (firstSeenIndex >= suppliers.size()) {
|
||||
countDown.pause();
|
||||
var r = fallback.query(prompt);
|
||||
|
@ -63,14 +65,14 @@ public class SecretQueryProgress {
|
|||
requestCancelled = true;
|
||||
return null;
|
||||
}
|
||||
if (shouldCache(fallback, prompt)) {
|
||||
SecretManager.set(ref, r.getSecret());
|
||||
}
|
||||
return r.getSecret();
|
||||
}
|
||||
|
||||
var ref = new SecretReference(storeId, firstSeenIndex);
|
||||
var sup = suppliers.get(firstSeenIndex);
|
||||
var shouldCache = sup.cache()
|
||||
&& SecretManager.shouldCacheForPrompt(prompt)
|
||||
&& !AppPrefs.get().dontCachePasswords().get();
|
||||
var shouldCache = shouldCache(sup, prompt);
|
||||
var wasLastPrompt = firstSeenIndex == seenPrompts.size() - 1;
|
||||
|
||||
// Clear cache if secret was wrong/queried again
|
||||
|
@ -114,4 +116,11 @@ public class SecretQueryProgress {
|
|||
}
|
||||
return r.getSecret();
|
||||
}
|
||||
|
||||
private boolean shouldCache(SecretQuery query, String prompt) {
|
||||
var shouldCache = query.cache()
|
||||
&& SecretManager.shouldCacheForPrompt(prompt)
|
||||
&& (!query.respectDontCacheSetting() || !AppPrefs.get().dontCachePasswords().get());
|
||||
return shouldCache;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue