Bug 1529273 - replaces the current implementation of Profile::new with dedicated Profile::new and Profile::new_from_path. r=ato

Differential Revision: https://phabricator.services.mozilla.com/D23310

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kriti Singh 2019-03-13 16:42:23 +00:00
Родитель cd795da219
Коммит 4438287276
3 изменённых файлов: 17 добавлений и 14 удалений

Просмотреть файл

@ -348,7 +348,7 @@ impl FirefoxOptions {
let profile_zip = &*base64::decode(profile_base64)?;
// Create an emtpy profile directory
let profile = Profile::new(None)?;
let profile = Profile::new()?;
unzip_buffer(
profile_zip,
profile

Просмотреть файл

@ -145,7 +145,7 @@ impl MarionetteHandler {
let mut profile = match options.profile {
Some(x) => x,
None => Profile::new(None)?,
None => Profile::new()?,
};
self.set_prefs(port, &mut profile, is_custom_profile, options.prefs)
@ -1523,7 +1523,7 @@ mod tests {
// several regressions related to marionette.log.level.
#[test]
fn test_marionette_log_level() {
let mut profile = Profile::new(None).unwrap();
let mut profile = Profile::new().unwrap();
let handler = MarionetteHandler::new(MarionetteSettings::default());
handler.set_prefs(2828, &mut profile, false, vec![]).ok();
let user_prefs = profile.user_prefs().unwrap();

Просмотреть файл

@ -16,18 +16,21 @@ pub struct Profile {
}
impl Profile {
pub fn new(opt_path: Option<&Path>) -> IoResult<Profile> {
let mut temp_dir = None;
let path = match opt_path {
Some(p) => p.to_path_buf(),
None => {
let dir = TempDir::new("rust_mozprofile")?;
let temp_path = dir.path().to_path_buf();
temp_dir = Some(dir);
temp_path
}
};
pub fn new() -> IoResult<Profile> {
let dir = TempDir::new("rust_mozprofile")?;
let path = dir.path().to_path_buf();
let temp_dir = Some(dir);
Ok(Profile {
path,
temp_dir,
prefs: None,
user_prefs: None,
})
}
pub fn new_from_path(p: &Path) -> IoResult<Profile> {
let path = p.to_path_buf();
let temp_dir = None;
Ok(Profile {
path,
temp_dir,