fix: blob leases could be broken by tmpwatch
Let's put them in an application-specific cache directory location instead. refs: #5422
This commit is contained in:
6 files changed
+27
-4
No files matched your search
@@ -1676,6 +1676,14 @@ fn default_font_size() -> f64 {
|
||||
12.0
|
||||
}
|
||||
|
||||
pub(crate) fn compute_cache_dir() -> anyhow::Result<PathBuf> {
|
||||
if let Some(runtime) = dirs_next::cache_dir() {
|
||||
return Ok(runtime.join("wezterm"));
|
||||
}
|
||||
|
||||
Ok(crate::HOME_DIR.join(".local/share/wezterm"))
|
||||
}
|
||||
|
||||
pub(crate) fn compute_data_dir() -> anyhow::Result<PathBuf> {
|
||||
if let Some(runtime) = dirs_next::data_dir() {
|
||||
return Ok(runtime.join("wezterm"));
|
||||
|
||||
@@ -67,6 +67,7 @@ lazy_static! {
|
||||
pub static ref CONFIG_DIRS: Vec<PathBuf> = config_dirs();
|
||||
pub static ref RUNTIME_DIR: PathBuf = compute_runtime_dir().unwrap();
|
||||
pub static ref DATA_DIR: PathBuf = compute_data_dir().unwrap();
|
||||
pub static ref CACHE_DIR: PathBuf = compute_cache_dir().unwrap();
|
||||
static ref CONFIG: Configuration = Configuration::new();
|
||||
static ref CONFIG_FILE_OVERRIDE: Mutex<Option<PathBuf>> = Mutex::new(None);
|
||||
static ref CONFIG_SKIP: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
@@ -81,6 +81,8 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
to @Mrreadiness! #5441 #5304
|
||||
* Search mode now accepts composed input from the IME. Thanks to @kenchou! #5564
|
||||
* Quick select mode will now accept unix paths with `//` in them. #5763
|
||||
* blob leases (for image rendering) could be removed by temporary directory
|
||||
cleaners, resulting in issues with rendering. #5422
|
||||
|
||||
#### Updated
|
||||
* Bundled conpty.dll and OpenConsole.exe to build 1.19.240130002.nupkg
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::{BlobStorage, BoxedReader, BufSeekRead, ContentId, Error, LeaseId};
|
||||
use std::collections::HashMap;
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, Write};
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Mutex;
|
||||
use tempfile::TempDir;
|
||||
|
||||
@@ -25,6 +25,19 @@ impl SimpleTempDir {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn new_in<P: AsRef<Path>>(path: P) -> Result<Self, Error> {
|
||||
let path = path.as_ref();
|
||||
std::fs::create_dir_all(path)?;
|
||||
let root = tempfile::Builder::new()
|
||||
.prefix("wezterm-blob-lease-")
|
||||
.rand_bytes(8)
|
||||
.tempdir_in(path)?;
|
||||
Ok(Self {
|
||||
root,
|
||||
refs: Mutex::new(HashMap::new()),
|
||||
})
|
||||
}
|
||||
|
||||
fn path_for_content(&self, content_id: ContentId) -> Result<PathBuf, Error> {
|
||||
let path = self.root.path().join(format!("{content_id}"));
|
||||
std::fs::create_dir_all(path.parent().unwrap())?;
|
||||
|
||||
@@ -414,9 +414,8 @@ async fn async_run_terminal_gui(
|
||||
config::RUNTIME_DIR.join(format!("gui-sock-{}", unsafe { libc::getpid() }));
|
||||
std::env::set_var("WEZTERM_UNIX_SOCKET", unix_socket_path.clone());
|
||||
wezterm_blob_leases::register_storage(Arc::new(
|
||||
wezterm_blob_leases::simple_tempdir::SimpleTempDir::new()?,
|
||||
wezterm_blob_leases::simple_tempdir::SimpleTempDir::new_in(&*config::CACHE_DIR)?,
|
||||
))?;
|
||||
|
||||
if let Err(err) = spawn_mux_server(unix_socket_path, should_publish) {
|
||||
log::warn!("{:#}", err);
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ fn run() -> anyhow::Result<()> {
|
||||
}
|
||||
|
||||
wezterm_blob_leases::register_storage(Arc::new(
|
||||
wezterm_blob_leases::simple_tempdir::SimpleTempDir::new()?,
|
||||
wezterm_blob_leases::simple_tempdir::SimpleTempDir::new_in(&*config::CACHE_DIR)?,
|
||||
))?;
|
||||
|
||||
let need_builder = !opts.prog.is_empty() || opts.cwd.is_some();
|
||||
|
||||
Reference in new issue
Block a user