paths: Replace lazy_static!
with OnceLock
(#13213)
This PR replaces the `lazy_static!` usages in the `paths` crate with `OnceLock` from the standard library. This allows us to drop the `lazy_static` dependency from this crate. The paths are now exposed as accessor functions that reference a private static value. Release Notes: - N/A
This commit is contained in:
parent
ba59e66314
commit
81475ac4cd
27 changed files with 322 additions and 172 deletions
|
@ -8,7 +8,7 @@ use http::Method;
|
|||
use isahc::config::Configurable;
|
||||
|
||||
use http::{self, HttpClient, HttpClientWithUrl};
|
||||
use paths::{CRASHES_DIR, CRASHES_RETIRED_DIR};
|
||||
use paths::{crashes_dir, crashes_retired_dir};
|
||||
use release_channel::ReleaseChannel;
|
||||
use release_channel::RELEASE_CHANNEL;
|
||||
use settings::Settings;
|
||||
|
@ -113,7 +113,7 @@ pub fn init_panic_hook(
|
|||
if !is_pty {
|
||||
if let Some(panic_data_json) = serde_json::to_string(&panic_data).log_err() {
|
||||
let timestamp = chrono::Utc::now().format("%Y_%m_%d %H_%M_%S").to_string();
|
||||
let panic_file_path = paths::LOGS_DIR.join(format!("zed-{}.panic", timestamp));
|
||||
let panic_file_path = paths::logs_dir().join(format!("zed-{}.panic", timestamp));
|
||||
let panic_file = std::fs::OpenOptions::new()
|
||||
.append(true)
|
||||
.create(true)
|
||||
|
@ -368,7 +368,7 @@ async fn upload_previous_panics(
|
|||
telemetry_settings: client::TelemetrySettings,
|
||||
) -> Result<Option<(i64, String)>> {
|
||||
let panic_report_url = http.build_zed_api_url("/telemetry/panics", &[])?;
|
||||
let mut children = smol::fs::read_dir(&*paths::LOGS_DIR).await?;
|
||||
let mut children = smol::fs::read_dir(paths::logs_dir()).await?;
|
||||
|
||||
let mut most_recent_panic = None;
|
||||
|
||||
|
@ -460,8 +460,8 @@ async fn upload_previous_crashes(
|
|||
|
||||
let crash_report_url = http.build_zed_api_url("/telemetry/crashes", &[])?;
|
||||
|
||||
// crash directories are only set on MacOS
|
||||
for dir in [&*CRASHES_DIR, &*CRASHES_RETIRED_DIR]
|
||||
// Crash directories are only set on macOS.
|
||||
for dir in [crashes_dir(), crashes_retired_dir()]
|
||||
.iter()
|
||||
.filter_map(|d| d.as_deref())
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue