Skip to content

Commit acf5dcf

Browse files
authored
Merge pull request #157 from DeterminateSystems/graham/fh-991-feature-flapping
Graham/fh 991 feature flapping
2 parents 09c00a0 + 19f097f commit acf5dcf

File tree

10 files changed

+826
-780
lines changed

10 files changed

+826
-780
lines changed

Cargo.lock

Lines changed: 801 additions & 743 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gha-cache/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn main() {
66
];
77

88
for entry in &proto_source_files {
9-
println!("cargo:rerun-if-changed={}", entry);
9+
println!("cargo:rerun-if-changed={entry}");
1010
}
1111

1212
prost_build::Config::new()

gha-cache/src/api.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl fmt::Display for ApiErrorInfo {
263263
write!(f, "[Unstructured] {}", String::from_utf8_lossy(bytes))
264264
}
265265
Self::Structured(e) => {
266-
write!(f, "{:?}", e)
266+
write!(f, "{e:?}")
267267
}
268268
}
269269
}
@@ -284,7 +284,7 @@ impl Api {
284284
headers.insert("Authorization", auth_header);
285285
headers.insert(
286286
"Accept",
287-
HeaderValue::from_str(&format!("application/json;api-version={}", API_VERSION))
287+
HeaderValue::from_str(&format!("application/json;api-version={API_VERSION}"))
288288
.map_err(Error::init_error)?,
289289
);
290290

@@ -358,7 +358,7 @@ impl Api {
358358
.map(char::from)
359359
.collect();
360360

361-
let full_key = format!("{}-{}", key, nonce);
361+
let full_key = format!("{key}-{nonce}");
362362

363363
match self.allocate_file(&full_key).await {
364364
Ok(allocation) => {

magic-nix-cache/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ hyper = { version = "1.0.0", features = ["full"] }
5959
hyper-util = { version = "0.1", features = ["tokio", "server-auto", "http1"] }
6060
xdg = { version = "2.5.2" }
6161
color-eyre = { version = "0.6.3" }
62-
detsys-ids-client = "0.5.0"
62+
detsys-ids-client = "0.6"
6363

6464
[dependencies.tokio]
6565
version = "1.44.2"

magic-nix-cache/src/binary_cache.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async fn get_narinfo(
4646
}
4747

4848
let store_path_hash = components[0].to_string();
49-
let key = format!("{}.narinfo", store_path_hash);
49+
let key = format!("{store_path_hash}.narinfo");
5050

5151
if state
5252
.narinfo_negative_cache
@@ -92,14 +92,12 @@ async fn put_narinfo(
9292
let gha_cache = state.gha_cache.as_ref().ok_or(Error::GHADisabled)?;
9393

9494
let store_path_hash = components[0].to_string();
95-
let key = format!("{}.narinfo", store_path_hash);
95+
let key = format!("{store_path_hash}.narinfo");
9696
let allocation = gha_cache.api.allocate_file_with_random_suffix(&key).await?;
9797

9898
let body_stream = body.into_data_stream();
99-
let stream = StreamReader::new(
100-
body_stream
101-
.map(|r| r.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))),
102-
);
99+
let stream =
100+
StreamReader::new(body_stream.map(|r| r.map_err(|e| std::io::Error::other(e.to_string()))));
103101

104102
gha_cache.api.upload_file(allocation, stream).await?;
105103
state.metrics.narinfos_uploaded.incr();
@@ -128,7 +126,7 @@ async fn get_nar(Extension(state): Extension<State>, Path(path): Path<String>) -
128126

129127
if let Some(upstream) = &state.upstream {
130128
state.metrics.nars_sent_upstream.incr();
131-
Ok(Redirect::temporary(&format!("{}/nar/{}", upstream, path)))
129+
Ok(Redirect::temporary(&format!("{upstream}/nar/{path}")))
132130
} else {
133131
Err(Error::NotFound)
134132
}
@@ -147,10 +145,8 @@ async fn put_nar(
147145
.await?;
148146

149147
let body_stream = body.into_data_stream();
150-
let stream = StreamReader::new(
151-
body_stream
152-
.map(|r| r.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))),
153-
);
148+
let stream =
149+
StreamReader::new(body_stream.map(|r| r.map_err(|e| std::io::Error::other(e.to_string()))));
154150

155151
gha_cache.api.upload_file(allocation, stream).await?;
156152
state.metrics.nars_uploaded.incr();
@@ -160,7 +156,7 @@ async fn put_nar(
160156

161157
fn pull_through(state: &State, path: &str) -> Result<Redirect> {
162158
if let Some(upstream) = &state.upstream {
163-
Ok(Redirect::temporary(&format!("{}/{}", upstream, path)))
159+
Ok(Redirect::temporary(&format!("{upstream}/{path}")))
164160
} else {
165161
Err(Error::NotFound)
166162
}

magic-nix-cache/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ impl IntoResponse for Error {
6767
_ => StatusCode::INTERNAL_SERVER_ERROR,
6868
};
6969

70-
(code, format!("{}", self)).into_response()
70+
(code, format!("{self}")).into_response()
7171
}
7272
}

magic-nix-cache/src/flakehub.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ pub async fn init_cache(
7171
netrc_file
7272
.write_all(
7373
format!(
74-
"\nmachine {} login {} password {}\n\n",
75-
flakehub_cache_server_hostname, flakehub_login, flakehub_password,
74+
"\nmachine {flakehub_cache_server_hostname} login {flakehub_login} password {flakehub_password}\n\n",
7675
)
7776
.as_bytes(),
7877
)
@@ -138,13 +137,13 @@ pub async fn init_cache(
138137
let cache_name = {
139138
let mut url = flakehub_api_server
140139
.join("project")
141-
.map_err(|_| Error::Config(format!("bad URL '{}'", flakehub_api_server)))?;
140+
.map_err(|_| Error::Config(format!("bad URL '{flakehub_api_server}'")))?;
142141

143142
if let Some(flakehub_flake_name) = flakehub_flake_name {
144143
if !flakehub_flake_name.is_empty() {
145144
url = flakehub_api_server
146-
.join(&format!("project/{}", flakehub_flake_name))
147-
.map_err(|_| Error::Config(format!("bad URL '{}'", flakehub_api_server)))?;
145+
.join(&format!("project/{flakehub_flake_name}"))
146+
.map_err(|_| Error::Config(format!("bad URL '{flakehub_api_server}'")))?;
148147
}
149148
}
150149

@@ -257,14 +256,12 @@ async fn extract_info_from_netrc(
257256
.to_string();
258257
let flakehub_login = flakehub_netrc_entry.login.ok_or_else(|| {
259258
Error::Config(format!(
260-
"netrc file does not contain a login for '{}'",
261-
flakehub_api_server
259+
"netrc file does not contain a login for '{flakehub_api_server}'"
262260
))
263261
})?;
264262
let flakehub_password = flakehub_netrc_entry.password.ok_or_else(|| {
265263
Error::Config(format!(
266-
"netrc file does not contain a password for '{}'",
267-
flakehub_api_server
264+
"netrc file does not contain a password for '{flakehub_api_server}'"
268265
))
269266
})?;
270267

magic-nix-cache/src/gha.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,7 @@ async fn upload_path(
176176

177177
let nar_stream = store.nar_from_path(path.clone());
178178

179-
let nar_reader = nar_stream
180-
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))
181-
.into_async_read();
179+
let nar_reader = nar_stream.map_err(std::io::Error::other).into_async_read();
182180

183181
let nar_compressor = ZstdEncoder::new(nar_reader.compat());
184182

@@ -197,7 +195,7 @@ async fn upload_path(
197195

198196
let narinfo_allocation = api.allocate_file_with_random_suffix(&narinfo_path).await?;
199197

200-
let narinfo = path_info_to_nar_info(store.clone(), &path_info, format!("nar/{}", nar_path))
198+
let narinfo = path_info_to_nar_info(store.clone(), &path_info, format!("nar/{nar_path}"))
201199
.to_string()
202200
.expect("failed to convert path into to nar info");
203201

magic-nix-cache/src/github.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ pub(crate) fn print_unauthenticated_error() {
4848
);
4949
}
5050
};
51-
println!("{}", msg);
51+
println!("{msg}");
5252
}

magic-nix-cache/src/main.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,7 @@ async fn main_cli(args: Args, recorder: detsys_ids_client::Recorder) -> Result<(
296296
)
297297
.await;
298298
recorder
299-
.set_fact(
300-
"dnixd_availability",
301-
format!("{:?}", dnixd_available).into(),
302-
)
299+
.set_fact("dnixd_availability", format!("{dnixd_available:?}").into())
303300
.await;
304301

305302
let flakehub_auth_method: Option<FlakeHubAuthSource> = match (
@@ -356,7 +353,7 @@ async fn main_cli(args: Args, recorder: detsys_ids_client::Recorder) -> Result<(
356353
recorder
357354
.set_fact(
358355
"flakehub_auth_method",
359-
format!("{:?}", flakehub_auth_method).into(),
356+
format!("{flakehub_auth_method:?}").into(),
360357
)
361358
.await;
362359

0 commit comments

Comments
 (0)