Skip to content

Commit 4d182a8

Browse files
committed
fix cache dir not being created
1 parent f87676e commit 4d182a8

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

data/src/dir_manager.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ impl DirManager {
124124
project_dirs.data_local_dir().to_path_buf()
125125
};
126126

127+
if !state_dir_path.exists()
128+
&& let Err(e) = fs::create_dir_all(&state_dir_path)
129+
{
130+
error!("Can't create state directories: {e}.")
131+
}
132+
127133
let state = {
128134
let state_file_path = state_dir_path.join(STATE_FILENAME);
129135

@@ -140,13 +146,21 @@ impl DirManager {
140146
}
141147
};
142148

149+
let cache_dir_path = project_dirs.cache_dir().to_path_buf();
150+
151+
if !cache_dir_path.exists()
152+
&& let Err(e) = fs::create_dir_all(&cache_dir_path)
153+
{
154+
error!("Can't create cache directories: {e}.")
155+
}
156+
143157
DirManager {
144158
config_names,
145159
config_dir_path,
146160
settings,
147161
state,
148162
state_dir_path,
149-
cache_dir_path: project_dirs.cache_dir().to_path_buf(),
163+
cache_dir_path,
150164
}
151165
}
152166

ui/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ tokio = { workspace = true, features = ["time"] }
2626
open.workspace = true
2727
libcosmic.workspace = true
2828
constcat.workspace = true
29-
directories.workspace = true
3029
anyhow.workspace = true
3130
fslock.workspace = true
3231
resvg.workspace = true

ui/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ use crate::config_dialogs::{
4444
};
4545
use crate::udev_dialog::UdevDialogMsg;
4646

47-
use common::{APP, ORG, QUALIFIER};
48-
use directories::ProjectDirs;
4947
use fslock::LockFile;
5048

5149
#[macro_use]
@@ -84,8 +82,7 @@ pub fn run_ui<H: HardwareBridge + 'static>(mut app_state: AppState<H>) {
8482
let _ = std::fs::create_dir_all("temp");
8583
PathBuf::from("temp").join("app.lock")
8684
} else {
87-
let project_dirs = ProjectDirs::from(QUALIFIER, ORG, APP).unwrap();
88-
project_dirs.cache_dir().join("app.lock")
85+
app_state.dir_manager.cache_dir_path.join("app.lock")
8986
};
9087
let mut app_lock = LockFile::open(&instance_lock_path).expect("Failed to open app lock file");
9188
if !app_lock.try_lock_with_pid().unwrap_or(false) {

0 commit comments

Comments
 (0)