| 440 | } |
| 441 | |
| 442 | fn claim_session( |
| 443 | &self, |
| 444 | grant: &SandboxGrant, |
| 445 | session_id: &str, |
| 446 | unused: bool, |
| 447 | ) -> Result<bool, GrantError> { |
| 448 | let mut registry = self.lock(); |
| 449 | let key = (grant.repository_id.clone(), session_id.to_string()); |
| 450 | Ok(match registry.sessions.get(&key) { |
| 451 | Some(existing) => *existing == owner(grant), |
| 452 | None if unused => { |
| 453 | registry.sessions.insert(key, owner(grant)); |
| 454 | true |
| 455 | } |
| 456 | None => false, |
| 457 | }) |
| 458 | } |
| 459 | |
| 460 | fn owns_session(&self, grant: &SandboxGrant, session_id: &str) -> Result<bool, GrantError> { |
| 461 | let key = (grant.repository_id.clone(), session_id.to_string()); |