Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue creating directories in firefox profiles. #69

Merged
merged 1 commit into from Jun 6, 2016

Conversation

jgraham
Copy link
Member

@jgraham jgraham commented Jun 3, 2016

This change is Reviewable

When the firefox profile contained multiple directories, we failed to
correctly create the directories in the destination profile folder. This
fix assumes that any file with a name ending / in a zip archive is a
directory.
if !dir.exists() {
try!(fs::create_dir_all(dir));
let name = file.name();
let is_dir = name.ends_with("/");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, what's the advantage of this method compared to Path.is_dir() ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the directory doesn't actually exist yet, so Path.is_dir() will always be false.

@JohanLorenzo
Copy link

I confirm this patch allows extracting this archive correctly. The profile is then correctly pushed to Firefox.

Before the patch, wires just failed with a cryptic error:

DEBUG:wires::marionette: Got NewSession command
DEBUG:webdriver::command: Getting firefox_profile from capabilities
DEBUG:wires::marionette: Using custom profile
INFO:mozprofile::profile: Using profile path /tmp/rust_mozprofile.TwbAvDzFI2wb
DEBUG:webdriver::server: Returning status InternalServerError
DEBUG:webdriver::server: Returning body {"error":"unknown error","message":"other os error"}
DEBUG:hyper::server::response: writing head: Http11 InternalServerError
DEBUG:hyper::server::response: headers [
Headers { Date: Fri, 03 Jun 2016 10:04:03 GMT, Content-Length: 52, Content-Type: application/json, Connection: close, }]
DEBUG:hyper::server::response: write 52 bytes
DEBUG:hyper::server: keep_alive = false for 127.0.0.1:60516
DEBUG:hyper::server: keep_alive loop ending for 127.0.0.1:60516
ERROR  { [WebDriverError: Unable to parse new session response: {"error":"unknown error","message":"other os error"}] name: 'WebDriverError' }

@jgraham
Copy link
Member Author

jgraham commented Jun 3, 2016

r? @andreastt

@andreastt
Copy link
Contributor

@jgraham Are the changes to Cargo.lock here related to the patch? If not, can you apply that in a separate commit?

@jgraham
Copy link
Member Author

jgraham commented Jun 6, 2016

Not really related I don't think. I can break this up.

@andreastt
Copy link
Contributor

Reviewed 1 of 2 files at r1.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


src/marionette.rs, line 384 [r1] (raw file):

        let unzip_path = {
            let name = file.name();
            let is_dir = name.ends_with("/");

I’m a bit surprised that zip::read::ZipFile does not offer an is_dir() function or similar, but this does the trick from what I can tell.


Comments from Reviewable

@andreastt
Copy link
Contributor

:lgtm:

Previously, jgraham wrote…

Not really related I don't think. I can break this up.


Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@jgraham jgraham merged commit 644db2a into master Jun 6, 2016
@whimboo whimboo deleted the profile_directories branch June 6, 2017 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants