MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / persist

Method persist

crates/opencode-provider/src/auth.rs:140–160  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

138 }
139
140 async fn persist(&self) -> anyhow::Result<()> {
141 let Some(path) = self.filepath.as_ref() else {
142 return Ok(());
143 };
144
145 if let Some(parent) = path.parent() {
146 tokio::fs::create_dir_all(parent).await?;
147 }
148
149 let creds = self.credentials.read().await;
150 let json = serde_json::to_vec_pretty(&*creds)?;
151 tokio::fs::write(path, json).await?;
152
153 #[cfg(unix)]
154 {
155 use std::os::unix::fs::PermissionsExt;
156 tokio::fs::set_permissions(path, std::fs::Permissions::from_mode(0o600)).await?;
157 }
158
159 Ok(())
160 }
161}
162
163impl Default for AuthManager {

Callers 2

setMethod · 0.45
removeMethod · 0.45

Calls 1

readMethod · 0.80

Tested by

no test coverage detected