oh builds for Windows bd630386001e
Its configuration is written owner-only where the platform has Unix modes, and lives in %APPDATA%\oh on Windows, where HOME is usually unset.
- Author
- Andy McCall @andymccall <[email protected]>
- When
- · 2026-09-30 18:28 UTC
- Signature
- ✔ signed by Andy McCall
- Hash
bd630386001ed3d0fc0d03c01548c193a2297f90b6fedb00b5883259f9ca1ad0- Depends on
- 5c6e92fd8d71
- Depended on by
- nothing yet
- In bookmarks
- api-unknown-fields cancel-landed-runs clear-waiting close-proposal-140 diffusion-pin-bookmark draft-ready image-check job-waits main oh-comment-body-file proposal-list-fast run-one-job wiki-says-so
- In tags
- v0.1.0 v0.2.0 v0.3.0 v0.3.1 v0.4.0 v0.4.1 v0.4.2 v0.5.0 v0.5.1 v0.5.2 v0.6.0 v0.6.1 v0.7.0 v0.8.0 v0.9.0 v0.9.1 v0.9.11 v0.9.15 v0.9.16 v0.9.19 v0.9.2 v0.9.20 v0.9.21 v0.9.22 v0.9.23 v0.9.24 v0.9.3 v0.9.4 v0.9.5 v0.9.6 v0.9.7 v0.9.8 v0.9.9
- Edits
- 4 atoms, 0 tree operations, 1 file
Browse the tree at this change
modified crates/oh/src/target.rs +11 −3
| … | 32 unchanged lines |
||
| 33 | 33 | } |
|
| 34 | 34 | let base = match std::env::var_os("XDG_CONFIG_HOME") { |
|
| 35 | 35 | Some(d) => PathBuf::from(d), |
|
| 36 | + | // Windows has no HOME as a rule: the roaming profile's application data. |
|
| 37 | + | #[cfg(windows)] |
|
| 38 | + | None => PathBuf::from(std::env::var_os("APPDATA").or_else(|| std::env::var_os("USERPROFILE")).context("APPDATA is not set")?), |
|
| 39 | + | #[cfg(not(windows))] |
|
| 36 | 40 | None => PathBuf::from(std::env::var_os("HOME").context("HOME is not set")?).join(".config"), |
|
| 37 | 41 | }; |
|
| 38 | 42 | Ok(base.join("oh").join("config.toml")) |
|
| … | 9 unchanged lines |
||
| 48 | 52 | } |
|
| 49 | 53 | } |
|
| 50 | 54 | ||
| 51 | - | /// Written owner-only: it holds tokens. |
|
| 55 | + | /// Written owner-only: it holds tokens. (On Windows the file sits in the |
|
| 56 | + | /// user's own profile, which only they and administrators can read.) |
|
| 52 | 57 | pub fn save(&self) -> Result<()> { |
|
| 53 | 58 | use std::io::Write; |
|
| 54 | - | use std::os::unix::fs::OpenOptionsExt; |
|
| 55 | 59 | let p = config_path()?; |
|
| 56 | 60 | std::fs::create_dir_all(p.parent().unwrap())?; |
|
| 57 | 61 | let tmp = p.with_extension("toml.tmp"); |
|
| 58 | - | let mut f = std::fs::OpenOptions::new().write(true).create(true).truncate(true).mode(0o600).open(&tmp)?; |
|
| 62 | + | let mut options = std::fs::OpenOptions::new(); |
|
| 63 | + | options.write(true).create(true).truncate(true); |
|
| 64 | + | #[cfg(unix)] |
|
| 65 | + | std::os::unix::fs::OpenOptionsExt::mode(&mut options, 0o600); |
|
| 66 | + | let mut f = options.open(&tmp)?; |
|
| 59 | 67 | f.write_all(toml::to_string_pretty(self)?.as_bytes())?; |
|
| 60 | 68 | f.sync_all()?; |
|
| 61 | 69 | std::fs::rename(&tmp, &p)?; |
|
| … | 126 unchanged lines |