Create config_dir if none exist for caching (#35761)

* Create config_dir if none exist for caching

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>

* remove specialized behaviour for ohos; copy prefs.json if necessary

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>

* downgrade the log to trace verbosity

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>

* update wpt-test

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This commit is contained in:
Euclid Ye 2025-03-19 02:36:33 +08:00 committed by GitHub
parent 9f93ccd942
commit 86957be5f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 40 additions and 7 deletions

View file

@ -128,7 +128,6 @@ fn get_preferences(opts_matches: &Matches, config_dir: &Option<PathBuf>) -> Pref
let user_prefs_path = config_dir
.clone()
.or_else(default_config_dir)
.map(|path| path.join("prefs.json"))
.filter(|path| path.exists());
let user_prefs_hash = user_prefs_path.map(read_prefs_file).unwrap_or_default();
@ -382,7 +381,18 @@ pub(crate) fn parse_command_line_arguments(args: Vec<String>) -> ArgumentParsing
process::exit(0);
};
let config_dir = opt_match.opt_str("config-dir").map(Into::into);
let config_dir = opt_match
.opt_str("config-dir")
.map(Into::into)
.or_else(default_config_dir)
.inspect(|path| {
if !path.exists() {
fs::create_dir_all(path).unwrap_or_else(|e| {
error!("Failed to create config directory at {:?}: {:?}", path, e)
})
}
});
let mut preferences = get_preferences(&opt_match, &config_dir);
// If this is the content process, we'll receive the real options over IPC. So just fill in