A fork of attic a self-hostable Nix Binary Cache server
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #252 from shivaraj-bh/max-nar-info-size

attic-server: Make `MAX_NAR_INFO_SIZE` configurable

authored by

Zhaofeng Li and committed by
GitHub
24fad062 a3fce5d5

+13 -6
+1 -6
server/src/api/v1/upload_path.rs
··· 55 55 /// TODO: Make this configurable 56 56 const CONCURRENT_CHUNK_UPLOADS: usize = 10; 57 57 58 - /// The maximum size of the upload info JSON. 59 - /// 60 - /// TODO: Make this configurable 61 - const MAX_NAR_INFO_SIZE: usize = 1 * 1024 * 1024; // 1 MiB 62 - 63 58 type CompressorFn<C> = Box<dyn FnOnce(C) -> Box<dyn AsyncRead + Unpin + Send> + Send>; 64 59 65 60 /// Data of a chunk. ··· 147 142 )) 148 143 })?; 149 144 150 - if preamble_size > MAX_NAR_INFO_SIZE { 145 + if preamble_size > state.config.max_nar_info_size { 151 146 return Err(ErrorKind::RequestError(anyhow!("Upload info is too large")).into()); 152 147 } 153 148
+3
server/src/config-template.toml
··· 19 19 # not `https://domain.tld/attic`). 20 20 #api-endpoint = "https://your.domain.tld/" 21 21 22 + # The maximum size of the upload info JSON, in bytes. 23 + #max-nar-info-size = 1048576 # 1 MiB 24 + 22 25 # Whether to soft-delete caches 23 26 # 24 27 # If this is enabled, caches are soft-deleted instead of actually
+9
server/src/config.rs
··· 102 102 #[serde(default = "default_require_proof_of_possession")] 103 103 pub require_proof_of_possession: bool, 104 104 105 + /// The maximum size of the upload info JSON, in bytes. 106 + #[serde(rename = "max-nar-info-size")] 107 + #[serde(default = "default_max_nar_info_size")] 108 + pub max_nar_info_size: usize, 109 + 105 110 /// Database connection. 106 111 pub database: DatabaseConfig, 107 112 ··· 553 558 554 559 fn default_default_retention_period() -> Duration { 555 560 Duration::ZERO 561 + } 562 + 563 + fn default_max_nar_info_size() -> usize { 564 + 1 * 1024 * 1024 // 1 MiB 556 565 } 557 566 558 567 fn load_config_from_path(path: &Path) -> Result<Config> {