aboutsummaryrefslogtreecommitdiffstats
path: root/ports/servoshell/egl/ohos/simpleservo.rs
diff options
context:
space:
mode:
authorEuclid Ye <yezhizhenjiakang@gmail.com>2025-03-19 02:36:33 +0800
committerGitHub <noreply@github.com>2025-03-18 18:36:33 +0000
commit86957be5f0ce387830fdd133e53837a57cc774ce (patch)
tree3188eddfa1ecf3d17e641acaccc460656dbb8398 /ports/servoshell/egl/ohos/simpleservo.rs
parent9f93ccd9427265f39f1a2de38389fec0e80f7bea (diff)
downloadservo-86957be5f0ce387830fdd133e53837a57cc774ce.tar.gz
servo-86957be5f0ce387830fdd133e53837a57cc774ce.zip
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>
Diffstat (limited to 'ports/servoshell/egl/ohos/simpleservo.rs')
-rw-r--r--ports/servoshell/egl/ohos/simpleservo.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/ports/servoshell/egl/ohos/simpleservo.rs b/ports/servoshell/egl/ohos/simpleservo.rs
index c4ccec07fce..708140e19a8 100644
--- a/ports/servoshell/egl/ohos/simpleservo.rs
+++ b/ports/servoshell/egl/ohos/simpleservo.rs
@@ -2,6 +2,7 @@
* 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/. */
use std::cell::RefCell;
+use std::fs;
use std::os::raw::c_void;
use std::path::PathBuf;
use std::ptr::NonNull;
@@ -40,6 +41,7 @@ pub fn init(
info!("Entered simpleservo init function");
crate::init_crypto();
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())));
// 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);
+ let config_dir = PathBuf::from(&options.cache_dir).join("servo");
+ debug!("Configs are located at: {:?}", config_dir);
let _ = crate::prefs::DEFAULT_CONFIG_DIR
- .set(resource_dir)
+ .set(config_dir.clone())
.inspect_err(|e| {
warn!(
"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) {
ArgumentParsingResult::ContentProcess(..) => {
unreachable!("OHOS does not have support for multiprocess yet.")