|
1 | 1 | use anyhow::{anyhow, Error};
|
2 | 2 | use serde::{Deserialize, Serialize};
|
| 3 | +use std::io::Write; |
3 | 4 | use std::{
|
4 | 5 | env,
|
5 | 6 | fs::{self, File},
|
6 | 7 | path::{Path, PathBuf},
|
7 | 8 | process::{Command, Stdio},
|
8 | 9 | };
|
9 |
| -use std::{io::Write, time::SystemTime}; |
10 | 10 | use tempfile::NamedTempFile;
|
11 | 11 | use url::Url;
|
12 | 12 |
|
13 | 13 | #[cfg(unix)]
|
14 | 14 | use std::os::unix::fs::PermissionsExt;
|
| 15 | +#[cfg(unix)] |
| 16 | +use std::time::SystemTime; |
15 | 17 |
|
16 | 18 | const BASE_URL: &str = "https://github.com/facebook/buck2/releases/download";
|
17 | 19 | const BUCK_RELEASE_URL: &str = "https://github.com/facebook/buck2/tags";
|
@@ -100,6 +102,8 @@ fn get_releases(path: &Path) -> Result<Vec<Release>, Error> {
|
100 | 102 | let mut releases_json_path = path.to_path_buf();
|
101 | 103 | releases_json_path.push("releases.json");
|
102 | 104 |
|
| 105 | + // TODO support last last_modification_time for windows users |
| 106 | + #[cfg(unix)] |
103 | 107 | if releases_json_path.exists() {
|
104 | 108 | use std::os::unix::fs::MetadataExt;
|
105 | 109 | let meta = fs::metadata(&releases_json_path)?;
|
@@ -177,8 +181,11 @@ fn download_http(version: String, output_dir: &Path) -> Result<PathBuf, Error> {
|
177 | 181 | let resp = reqwest::blocking::get(format!("{BASE_URL}/{version}/buck2-{arch}.zst"))?;
|
178 | 182 | zstd::stream::copy_decode(resp, &tmp_buck2_bin).unwrap();
|
179 | 183 | tmp_buck2_bin.flush()?;
|
180 |
| - let permissions = fs::Permissions::from_mode(0o755); |
181 |
| - fs::set_permissions(&tmp_buck2_bin, permissions)?; |
| 184 | + #[cfg(unix)] |
| 185 | + { |
| 186 | + let permissions = fs::Permissions::from_mode(0o755); |
| 187 | + fs::set_permissions(&tmp_buck2_bin, permissions)?; |
| 188 | + } |
182 | 189 | fs::rename(tmp_buck2_bin.path(), &buck2_path)?;
|
183 | 190 |
|
184 | 191 | // Also fetch the prelude hash and store it
|
|
0 commit comments