Make the cache at `root` and route its link to the handlers with `opened`'s token.
(
host: &Host,
opened: &SandboxOpened,
root: &Path,
skeleton: &SandboxSkeleton,
)
| 536 | /// Make the cache at `root` and route its link to the handlers with |
| 537 | /// `opened`'s token. |
| 538 | fn adopt( |
| 539 | host: &Host, |
| 540 | opened: &SandboxOpened, |
| 541 | root: &Path, |
| 542 | skeleton: &SandboxSkeleton, |
| 543 | ) -> Repository { |
| 544 | let repository = opened.repository.as_ref().unwrap(); |
| 545 | atomic_repository::write_remote_sandbox_pointer( |
| 546 | root, |
| 547 | &atomic_repository::RemoteSandboxPointer { |
| 548 | repository: atomic_repository::RemoteRepositoryRef { |
| 549 | authority: repository.authority.clone(), |
| 550 | repository_id: data_encoding::HEXLOWER.encode(&repository.repository_id), |
| 551 | }, |
| 552 | view: opened.view.clone(), |
| 553 | view_id: None, |
| 554 | token: String::from_utf8(opened.token.clone()).unwrap(), |
| 555 | }, |
| 556 | ) |
| 557 | .unwrap(); |
| 558 | routes().lock().unwrap().insert( |
| 559 | root.to_path_buf(), |
| 560 | Arc::new(Route { |
| 561 | state: Arc::clone(&host.state), |
| 562 | repository: opened.repository.clone().unwrap(), |
| 563 | token: opened.token.clone(), |
| 564 | rt: host.rt.handle().clone(), |
| 565 | }), |
| 566 | ); |
| 567 | let cache = Repository::create_remote_sandbox_cache(root, skeleton).unwrap(); |
| 568 | assert!(cache.is_remote_sandbox()); |
| 569 | cache |
| 570 | } |
| 571 | |
| 572 | // ── the tests ─────────────────────────────────────────────────────────── |
| 573 |