mirror of
https://github.com/telemt/telemt.git
synced 2026-10-07 09:55:57 +03:00
Hardswap Invariants in tests + Quota fixes
This commit is contained in:
@@ -122,6 +122,27 @@ impl Stats {
|
||||
self.quota_store.used(user)
|
||||
}
|
||||
|
||||
/// Returns quota ownership for the exact authenticated user incarnation.
|
||||
pub(crate) fn quota_handle_for_incarnation(
|
||||
&self,
|
||||
user: &str,
|
||||
incarnation: crate::proxy::user_admission::UserIncarnation,
|
||||
) -> Option<UserQuotaHandle> {
|
||||
if let Some(handle) = self.quota_store.handle_exact(user, incarnation) {
|
||||
return Some(handle);
|
||||
}
|
||||
if incarnation != 0 {
|
||||
return None;
|
||||
}
|
||||
let handle = self.quota_store.current_or_legacy_handle(user);
|
||||
(handle.incarnation() == incarnation).then_some(handle)
|
||||
}
|
||||
|
||||
/// Returns the currently published quota owner for compatibility relay entrypoints.
|
||||
pub(crate) fn current_user_quota_handle(&self, user: &str) -> UserQuotaHandle {
|
||||
self.quota_store.current_or_legacy_handle(user)
|
||||
}
|
||||
|
||||
pub fn load_user_quota_state(&self, user: &str, used_bytes: u64, last_reset_epoch_secs: u64) {
|
||||
self.quota_store
|
||||
.load(user, used_bytes, last_reset_epoch_secs);
|
||||
|
||||
Reference in New Issue
Block a user