evobench_tools/run/sub_command/
mod.rs

1use std::sync::Arc;
2
3use anyhow::Result;
4use chj_unix_util::polling_signals::PollingSignalsSender;
5
6use crate::run::{
7    config::{RunConfig, ShareableConfig},
8    polling_pool::PollingPool,
9    working_directory_pool::{
10        WorkingDirectoryPool, WorkingDirectoryPoolAndLock, WorkingDirectoryPoolBaseDir,
11        WorkingDirectoryPoolContext, WorkingDirectoryPoolOpts,
12    },
13};
14
15pub mod insert;
16pub mod list;
17pub mod list_all;
18pub mod wd;
19pub mod wd_log;
20
21// The reason to have these open_* functions here is just that making
22// them methods on the pools spams those files with
23// RunConfig/RunConfigBundle, and making them methods on RunConfig or
24// RunConfigBundle spams those.
25
26/// Takes `base_dir` since it needs to be constructed from what's in
27/// `conf` and `GlobalAppStateDir`, which is done way up in main, so
28/// we receive it from there, and we ignore the partially-duplicate
29/// piece of data in `conf`.
30pub fn open_working_directory_pool(
31    conf: &RunConfig,
32    base_dir: Arc<WorkingDirectoryPoolBaseDir>,
33    omit_check: bool,
34    signal_change: Option<PollingSignalsSender>,
35) -> Result<WorkingDirectoryPoolAndLock> {
36    let create_dir_if_not_exists = true;
37
38    let WorkingDirectoryPoolOpts {
39        // `base_dir` is ignored since we take `base_dir` as argument
40        // as described in the function doc
41        base_dir: _,
42        capacity,
43        auto_clean,
44    } = &*conf.working_directory_pool;
45
46    WorkingDirectoryPool::open(
47        WorkingDirectoryPoolContext {
48            capacity: *capacity,
49            auto_clean: auto_clean.clone(),
50            remote_repository_url: conf.remote_repository.url.clone(),
51            base_dir,
52            signal_change,
53        },
54        create_dir_if_not_exists,
55        omit_check,
56    )
57}
58
59pub fn open_polling_pool(config: &ShareableConfig) -> Result<PollingPool> {
60    PollingPool::open(
61        config.run_config.remote_repository.url.clone(),
62        config
63            .global_app_state_dir
64            .working_directory_for_polling_pool_base()?,
65    )
66}