From fea28db50530cb0dcf7dc7b708a1c9abcf4b08e6 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Tue, 14 Mar 2023 13:58:36 +0100 Subject: [PATCH] Revert to libstd's remove_dir_all instead of external crate. This avoids the Windows dependencies. The bug that caused us to switch to the crate in the first place was addressed in Rust 1.66+ (https://github.com/rust-lang/rust/pull/104558) --- Cargo.lock | 155 +++------------------------ glean-core/Cargo.toml | 1 - glean-core/src/event_database/mod.rs | 2 +- glean-core/src/lib.rs | 2 +- glean-core/src/ping/mod.rs | 2 +- 5 files changed, 17 insertions(+), 145 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d303a1758..4ab32d3752 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,15 +8,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aligned" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80a21b9440a626c7fc8573a9e3d3a06b75c7c97754c2949bc7857b90353ca655" -dependencies = [ - "as-slice", -] - [[package]] name = "android_log-sys" version = "0.2.0" @@ -47,15 +38,6 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" -[[package]] -name = "as-slice" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "516b6b4f0e40d50dcda9365d53964ec74560ad4284da2e7fc97122cd83174516" -dependencies = [ - "stable_deref_trait", -] - [[package]] name = "askama" version = "0.11.1" @@ -172,12 +154,6 @@ version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - [[package]] name = "cfg-if" version = "1.0.0" @@ -204,7 +180,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -213,7 +189,7 @@ version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "crossbeam-utils", ] @@ -223,7 +199,7 @@ version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "lazy_static", ] @@ -237,22 +213,13 @@ dependencies = [ "syn", ] -[[package]] -name = "cvt" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ac344c7efccb80cd25bc61b2170aec26f2f693fd40e765a539a1243db48c71" -dependencies = [ - "cfg-if 0.1.10", -] - [[package]] name = "dashmap" version = "4.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "num_cpus", ] @@ -338,28 +305,13 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0845fa252299212f0389d64ba26f34fa32cfe41588355f21ed507c59a0f64541" -[[package]] -name = "fs_at" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8012d245f5498f9e2510eb45b013372f43487ec88071ac8dfb82221d92f6ae1" -dependencies = [ - "aligned", - "cfg-if 1.0.0", - "cvt", - "libc", - "nix", - "smart-default", - "windows-sys 0.45.0", -] - [[package]] name = "getrandom" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "wasi 0.11.0+wasi-snapshot-preview1", ] @@ -422,7 +374,6 @@ dependencies = [ "log", "once_cell", "oslog", - "remove_dir_all", "rkv", "serde", "serde_json", @@ -505,7 +456,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -515,7 +466,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e" dependencies = [ "libc", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -533,7 +484,7 @@ dependencies = [ "hermit-abi", "io-lifetimes", "rustix", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -634,7 +585,7 @@ version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -674,18 +625,6 @@ dependencies = [ "adler", ] -[[package]] -name = "nix" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" -dependencies = [ - "bitflags", - "cfg-if 1.0.0", - "libc", - "static_assertions", -] - [[package]] name = "nom" version = "7.1.1" @@ -696,15 +635,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "normpath" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "972dec05f98e7c787ede35d7a9ea4735eb7788c299287352757b3def6cc1f7b5" -dependencies = [ - "windows-sys 0.45.0", -] - [[package]] name = "num-integer" version = "0.1.45" @@ -826,22 +756,6 @@ version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" -[[package]] -name = "remove_dir_all" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7174320e07c29945955cedd70b865995b286847111c8308d349a1f3a9e3af555" -dependencies = [ - "aligned", - "cfg-if 1.0.0", - "cvt", - "fs_at", - "lazy_static", - "libc", - "normpath", - "windows-sys 0.45.0", -] - [[package]] name = "rkv" version = "0.18.4" @@ -876,7 +790,7 @@ dependencies = [ "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -961,23 +875,6 @@ version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" -[[package]] -name = "smart-default" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "static_assertions" version = "1.1.0" @@ -1001,11 +898,11 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "fastrand", "redox_syscall", "rustix", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -1280,7 +1177,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb632c0076024630111a08ca9fcbd34736c80d10b9ae517077487b0c82f46a36" dependencies = [ "cc", - "cfg-if 1.0.0", + "cfg-if", "libc", ] @@ -1330,30 +1227,6 @@ dependencies = [ "windows_x86_64_msvc", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - [[package]] name = "windows_aarch64_gnullvm" version = "0.42.1" @@ -1426,7 +1299,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eeea3eb6a30ed24e374f59368d3917c5180a845fdd4ed6f1b2278811a9e826f8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "once_cell", ] diff --git a/glean-core/Cargo.toml b/glean-core/Cargo.toml index b06868f7a4..7f63b288fe 100644 --- a/glean-core/Cargo.toml +++ b/glean-core/Cargo.toml @@ -42,7 +42,6 @@ crossbeam-channel = "0.5" thiserror = "1.0.4" uniffi = { version = "0.23.0", default-features = false } time = "0.1.40" -remove_dir_all = "0.8.1" env_logger = { version = "0.10.0", default-features = false, optional = true } [target.'cfg(target_os = "android")'.dependencies] diff --git a/glean-core/src/event_database/mod.rs b/glean-core/src/event_database/mod.rs index c4f2b528b6..aee0d6164a 100644 --- a/glean-core/src/event_database/mod.rs +++ b/glean-core/src/event_database/mod.rs @@ -584,7 +584,7 @@ impl EventDatabase { // safe unwrap, only error case is poisoning let _lock = self.file_lock.write().unwrap(); - remove_dir_all::remove_dir_all(&self.path)?; + std::fs::remove_dir_all(&self.path)?; create_dir_all(&self.path)?; Ok(()) diff --git a/glean-core/src/lib.rs b/glean-core/src/lib.rs index 0cfcdb42b5..f83a19b47a 100644 --- a/glean-core/src/lib.rs +++ b/glean-core/src/lib.rs @@ -981,7 +981,7 @@ pub fn glean_test_destroy_glean(clear_stores: bool, data_path: Option) { INITIALIZE_CALLED.store(false, Ordering::SeqCst); } else if clear_stores { if let Some(data_path) = data_path { - let _ = remove_dir_all::remove_dir_all(data_path).ok(); + let _ = std::fs::remove_dir_all(data_path).ok(); } else { log::warn!("Asked to clear stores before initialization, but no data path given."); } diff --git a/glean-core/src/ping/mod.rs b/glean-core/src/ping/mod.rs index 42f1ebd951..6b342baf5c 100644 --- a/glean-core/src/ping/mod.rs +++ b/glean-core/src/ping/mod.rs @@ -358,7 +358,7 @@ impl PingMaker { pub fn clear_pending_pings(&self, data_path: &Path) -> Result<()> { let pings_dir = self.get_pings_dir(data_path, None)?; - remove_dir_all::remove_dir_all(&pings_dir)?; + std::fs::remove_dir_all(&pings_dir)?; create_dir_all(&pings_dir)?; log::debug!("All pending pings deleted");