mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
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:
parent
9f93ccd942
commit
86957be5f0
6 changed files with 40 additions and 7 deletions
|
@ -20,7 +20,7 @@ use devtools_traits::DevtoolsControlMsg;
|
||||||
use embedder_traits::EmbedderProxy;
|
use embedder_traits::EmbedderProxy;
|
||||||
use hyper_serde::Serde;
|
use hyper_serde::Serde;
|
||||||
use ipc_channel::ipc::{self, IpcReceiver, IpcReceiverSet, IpcSender};
|
use ipc_channel::ipc::{self, IpcReceiver, IpcReceiverSet, IpcSender};
|
||||||
use log::{debug, warn};
|
use log::{debug, trace, warn};
|
||||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||||
use net_traits::blob_url_store::parse_blob_url;
|
use net_traits::blob_url_store::parse_blob_url;
|
||||||
use net_traits::filemanager_thread::FileTokenCheck;
|
use net_traits::filemanager_thread::FileTokenCheck;
|
||||||
|
@ -496,7 +496,7 @@ where
|
||||||
let mut string_buffer: String = String::new();
|
let mut string_buffer: String = String::new();
|
||||||
match file.read_to_string(&mut string_buffer) {
|
match file.read_to_string(&mut string_buffer) {
|
||||||
Err(why) => panic!("couldn't read from {}: {}", display, why),
|
Err(why) => panic!("couldn't read from {}: {}", display, why),
|
||||||
Ok(_) => println!("successfully read from {}", display),
|
Ok(_) => trace!("successfully read from {}", display),
|
||||||
}
|
}
|
||||||
|
|
||||||
match serde_json::from_str(&string_buffer) {
|
match serde_json::from_str(&string_buffer) {
|
||||||
|
@ -523,7 +523,7 @@ where
|
||||||
|
|
||||||
match file.write_all(json_encoded.as_bytes()) {
|
match file.write_all(json_encoded.as_bytes()) {
|
||||||
Err(why) => panic!("couldn't write to {}: {}", display, why),
|
Err(why) => panic!("couldn't write to {}: {}", display, why),
|
||||||
Ok(_) => println!("successfully wrote to {}", display),
|
Ok(_) => trace!("successfully wrote to {}", display),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ pub struct InitOpts {
|
||||||
pub os_full_name: String,
|
pub os_full_name: String,
|
||||||
/// Path to application data bundled with the servo app, e.g. web-pages.
|
/// Path to application data bundled with the servo app, e.g. web-pages.
|
||||||
pub resource_dir: String,
|
pub resource_dir: String,
|
||||||
|
pub cache_dir: String,
|
||||||
pub display_density: f64,
|
pub display_density: f64,
|
||||||
pub commandline_args: String,
|
pub commandline_args: String,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
use std::fs;
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
@ -40,6 +41,7 @@ pub fn init(
|
||||||
info!("Entered simpleservo init function");
|
info!("Entered simpleservo init function");
|
||||||
crate::init_crypto();
|
crate::init_crypto();
|
||||||
let resource_dir = PathBuf::from(&options.resource_dir).join("servo");
|
let resource_dir = PathBuf::from(&options.resource_dir).join("servo");
|
||||||
|
debug!("Resources are located at: {:?}", resource_dir);
|
||||||
resources::set(Box::new(ResourceReaderInstance::new(resource_dir.clone())));
|
resources::set(Box::new(ResourceReaderInstance::new(resource_dir.clone())));
|
||||||
|
|
||||||
// It would be nice if `from_cmdline_args()` could accept str slices, to avoid allocations here.
|
// It would be nice if `from_cmdline_args()` could accept str slices, to avoid allocations here.
|
||||||
|
@ -53,8 +55,10 @@ pub fn init(
|
||||||
);
|
);
|
||||||
debug!("Servo commandline args: {:?}", args);
|
debug!("Servo commandline args: {:?}", args);
|
||||||
|
|
||||||
|
let config_dir = PathBuf::from(&options.cache_dir).join("servo");
|
||||||
|
debug!("Configs are located at: {:?}", config_dir);
|
||||||
let _ = crate::prefs::DEFAULT_CONFIG_DIR
|
let _ = crate::prefs::DEFAULT_CONFIG_DIR
|
||||||
.set(resource_dir)
|
.set(config_dir.clone())
|
||||||
.inspect_err(|e| {
|
.inspect_err(|e| {
|
||||||
warn!(
|
warn!(
|
||||||
"Default Prefs Dir already previously filled. Got error {}",
|
"Default Prefs Dir already previously filled. Got error {}",
|
||||||
|
@ -62,6 +66,18 @@ pub fn init(
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Try copy `prefs.json` from {this.context.resource_prefsDir}/servo/
|
||||||
|
// to `config_dir` if none exist
|
||||||
|
let source_prefs = resource_dir.join("prefs.json");
|
||||||
|
let target_prefs = config_dir.join("prefs.json");
|
||||||
|
if !target_prefs.exists() && source_prefs.exists() {
|
||||||
|
debug!("Copy {:?} to {:?}", source_prefs, target_prefs);
|
||||||
|
fs::copy(&source_prefs, &target_prefs).unwrap_or_else(|e| {
|
||||||
|
debug!("Copy failed! {:?}", e);
|
||||||
|
0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let (opts, preferences, servoshell_preferences) = match parse_command_line_arguments(args) {
|
let (opts, preferences, servoshell_preferences) = match parse_command_line_arguments(args) {
|
||||||
ArgumentParsingResult::ContentProcess(..) => {
|
ArgumentParsingResult::ContentProcess(..) => {
|
||||||
unreachable!("OHOS does not have support for multiprocess yet.")
|
unreachable!("OHOS does not have support for multiprocess yet.")
|
||||||
|
|
|
@ -128,7 +128,6 @@ fn get_preferences(opts_matches: &Matches, config_dir: &Option<PathBuf>) -> Pref
|
||||||
|
|
||||||
let user_prefs_path = config_dir
|
let user_prefs_path = config_dir
|
||||||
.clone()
|
.clone()
|
||||||
.or_else(default_config_dir)
|
|
||||||
.map(|path| path.join("prefs.json"))
|
.map(|path| path.join("prefs.json"))
|
||||||
.filter(|path| path.exists());
|
.filter(|path| path.exists());
|
||||||
let user_prefs_hash = user_prefs_path.map(read_prefs_file).unwrap_or_default();
|
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);
|
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);
|
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
|
// If this is the content process, we'll receive the real options over IPC. So just fill in
|
||||||
|
|
|
@ -17,6 +17,7 @@ interface InitOpts {
|
||||||
deviceType: string,
|
deviceType: string,
|
||||||
osFullName: string,
|
osFullName: string,
|
||||||
resourceDir: string,
|
resourceDir: string,
|
||||||
|
cacheDir: string,
|
||||||
displayDensity: number,
|
displayDensity: number,
|
||||||
commandlineArgs: string,
|
commandlineArgs: string,
|
||||||
}
|
}
|
||||||
|
@ -109,13 +110,16 @@ struct Index {
|
||||||
.onLoad((xComponentContext) => {
|
.onLoad((xComponentContext) => {
|
||||||
this.xComponentContext = xComponentContext as ServoXComponentInterface;
|
this.xComponentContext = xComponentContext as ServoXComponentInterface;
|
||||||
let resource_dir: string = this.context.resourceDir;
|
let resource_dir: string = this.context.resourceDir;
|
||||||
console.debug("Resources are located at %{public}s", resource_dir);
|
let cache_dir: string = this.context.cacheDir;
|
||||||
|
console.debug("resourceDir: ", resource_dir);
|
||||||
|
console.debug("cacheDir: ", cache_dir);
|
||||||
let init_options: InitOpts = {
|
let init_options: InitOpts = {
|
||||||
url: this.urlToLoad,
|
url: this.urlToLoad,
|
||||||
deviceType: get_device_type(),
|
deviceType: get_device_type(),
|
||||||
osFullName: deviceInfo.osFullName,
|
osFullName: deviceInfo.osFullName,
|
||||||
displayDensity: get_density(),
|
displayDensity: get_density(),
|
||||||
resourceDir: resource_dir,
|
resourceDir: resource_dir,
|
||||||
|
cacheDir: cache_dir,
|
||||||
commandlineArgs: this.CommandlineArgs
|
commandlineArgs: this.CommandlineArgs
|
||||||
}
|
}
|
||||||
this.xComponentContext.initServo(init_options)
|
this.xComponentContext.initServo(init_options)
|
||||||
|
|
2
tests/wpt/meta/webstorage/storage_local_setitem_quotaexceedederr.window.js.ini
vendored
Normal file
2
tests/wpt/meta/webstorage/storage_local_setitem_quotaexceedederr.window.js.ini
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[storage_local_setitem_quotaexceedederr.window.html]
|
||||||
|
expected: TIMEOUT
|
Loading…
Add table
Add a link
Reference in a new issue