mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-03-10 07:21:25 +00:00
pipeline-snapshot: Use user_cache_dir from the GLib
The 'dirs' crate doesn't behave the same leading to incompatibility Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1956>
This commit is contained in:
parent
2a11f0b577
commit
50472dc22c
3 changed files with 26 additions and 63 deletions
49
Cargo.lock
generated
49
Cargo.lock
generated
|
@ -1657,27 +1657,6 @@ dependencies = [
|
||||||
"subtle",
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dirs"
|
|
||||||
version = "6.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"
|
|
||||||
dependencies = [
|
|
||||||
"dirs-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dirs-sys"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"option-ext",
|
|
||||||
"redox_users",
|
|
||||||
"windows-sys 0.59.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "displaydoc"
|
name = "displaydoc"
|
||||||
version = "0.2.5"
|
version = "0.2.5"
|
||||||
|
@ -3236,7 +3215,6 @@ dependencies = [
|
||||||
"async-tungstenite",
|
"async-tungstenite",
|
||||||
"atomic_refcell",
|
"atomic_refcell",
|
||||||
"chrono",
|
"chrono",
|
||||||
"dirs",
|
|
||||||
"etherparse",
|
"etherparse",
|
||||||
"futures",
|
"futures",
|
||||||
"gst-plugin-version-helper",
|
"gst-plugin-version-helper",
|
||||||
|
@ -4781,16 +4759,6 @@ version = "0.2.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
|
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libredox"
|
|
||||||
version = "0.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.8.0",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "librespot-audio"
|
name = "librespot-audio"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
|
@ -5492,12 +5460,6 @@ dependencies = [
|
||||||
"vcpkg",
|
"vcpkg",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "option-ext"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "option-operations"
|
name = "option-operations"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
|
@ -6314,17 +6276,6 @@ dependencies = [
|
||||||
"bitflags 2.8.0",
|
"bitflags 2.8.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "redox_users"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b"
|
|
||||||
dependencies = [
|
|
||||||
"getrandom 0.2.15",
|
|
||||||
"libredox",
|
|
||||||
"thiserror 2.0.11",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.11.1"
|
version = "1.11.1"
|
||||||
|
|
|
@ -15,7 +15,6 @@ regex = "1"
|
||||||
atomic_refcell = "0.1"
|
atomic_refcell = "0.1"
|
||||||
pcap-file = "1.1.1"
|
pcap-file = "1.1.1"
|
||||||
etherparse = "0.16.0"
|
etherparse = "0.16.0"
|
||||||
dirs = "6"
|
|
||||||
chrono = "0.4.35"
|
chrono = "0.4.35"
|
||||||
walkdir = "2"
|
walkdir = "2"
|
||||||
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::{Path, PathBuf};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::{Arc, Mutex, RwLock};
|
use std::sync::{Arc, Mutex, RwLock};
|
||||||
use tokio::runtime;
|
use tokio::runtime;
|
||||||
|
@ -230,7 +230,7 @@ impl Settings {
|
||||||
fn set_xdg_cache(&mut self, xdg_cache: bool) {
|
fn set_xdg_cache(&mut self, xdg_cache: bool) {
|
||||||
self.xdg_cache = xdg_cache;
|
self.xdg_cache = xdg_cache;
|
||||||
if xdg_cache {
|
if xdg_cache {
|
||||||
let mut path = dirs::cache_dir().expect("Failed to find cache directory");
|
let mut path = gst::glib::user_cache_dir();
|
||||||
path.push("gstreamer-dots");
|
path.push("gstreamer-dots");
|
||||||
self.dot_dir = path.to_str().map(|s| s.to_string());
|
self.dot_dir = path.to_str().map(|s| s.to_string());
|
||||||
}
|
}
|
||||||
|
@ -630,19 +630,32 @@ impl PipelineSnapshot {
|
||||||
settings.dot_prefix.as_ref().map_or("", |s| s.as_str()),
|
settings.dot_prefix.as_ref().map_or("", |s| s.as_str()),
|
||||||
pipeline.name(),
|
pipeline.name(),
|
||||||
);
|
);
|
||||||
gst::debug!(CAT, imp = self, "Writing {}", dot_path);
|
|
||||||
match std::fs::File::create(&dot_path) {
|
|
||||||
Ok(mut f) => {
|
|
||||||
let data = pipeline.debug_to_dot_data(gst::DebugGraphDetails::all());
|
let data = pipeline.debug_to_dot_data(gst::DebugGraphDetails::all());
|
||||||
if let Err(e) = f.write_all(data.as_bytes()) {
|
|
||||||
|
if let Err(e) = self.write_dot_file_atomically(Path::new(&dot_path), data.as_bytes()) {
|
||||||
gst::warning!(CAT, imp = self, "Failed to write {}: {}", dot_path, e);
|
gst::warning!(CAT, imp = self, "Failed to write {}: {}", dot_path, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
|
||||||
gst::warning!(CAT, imp = self, "Failed to create {}: {}", dot_path, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn write_dot_file_atomically(&self, path: &Path, data: &[u8]) -> std::io::Result<()> {
|
||||||
|
// Create a temporary file in the same directory
|
||||||
|
let tmp_path = path.with_extension("dot.tmp");
|
||||||
|
|
||||||
|
// Write data to temporary file
|
||||||
|
{
|
||||||
|
let mut tmp_file = std::fs::File::create(&tmp_path)?;
|
||||||
|
tmp_file.write_all(data)?;
|
||||||
|
|
||||||
|
// Ensure all data is written to disk
|
||||||
|
tmp_file.sync_all()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Atomically rename temporary file to target path
|
||||||
|
std::fs::rename(tmp_path, path)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
|
Loading…
Reference in a new issue