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

Regex match (now basename) #137

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tbeason
Copy link
Contributor

@tbeason tbeason commented Feb 5, 2018

I had trouble with escape butchering a folderpath into a filename. I found that using a simple regex match to pick off the filename solved my problems. Don't know if other people might have had this issue as well. I'm on Windows 7 and Julia v0.7.

I had trouble with `escape` butchering a folderpath into a filename. I found that using a simple regex match to pick off the filename solved my problems. Don't know if other people might have had this issue as well. I'm on Windows 7 and Julia v0.7.
@tkelman
Copy link
Contributor

tkelman commented Feb 5, 2018

I had trouble with escape butchering a folderpath into a filename.

Can you please elaborate?

@tbeason
Copy link
Contributor Author

tbeason commented Feb 5, 2018

Sorry, wasn't sure how to explain that. JuliaStrings/StringEncodings.jl#22 is the relevant issue. If you look at the line that errors, it says

ERROR: The system cannot find the file specified.
C:\Users\tbeason\.julia\v0.7\WinRPM\cache\2\noarch%2Fmingw64-win_iconv-dll-0.0.8-3.15.noarch.cpio

and when I looked in the folder, I saw this

λ ls -1 C:\Users\tbeason\.julia\v0.7\WinRPM\cache\2
mingw64-win_iconv-dll-0.0.8-3.15.noarch.cpio
noarch%2Fmingw64-win_iconv-dll-0.0.8-3.15.noarch.rpm
repodata%2F58a3da7b6a7a7cf1c71a355252e0d9db1aab60162e9017b2235f5fa7a118660f-primary.xml
repodata%2Frepomd.xml

So you see that the *.cpio file does not have the noarch%2F on its front, and that is why it can't be found. The noarch%2F is a result of escape(path) because the path begins noarch/.... So what this regex does is just essentially drop the noarch/ from the beginning of the filename.

It is unclear to me why some files were written with the noarch%2F beginning and some were not in the first place, which may be where you want to look if my solution isn't the correct one. But this did fix the issue on my system. Not a problem with escape per se, which is definitely how my description could have been interpreted.

@tkelman
Copy link
Contributor

tkelman commented Feb 5, 2018

I suspect this would not work on julia 0.6, and is a difference in behavior between the different versions of 7zip bundled in julia 0.6 vs nightly.

src/WinRPM.jl Outdated
@@ -458,7 +458,7 @@ function do_install(package::Package)
error("failed to download $name $(data[2]) from $source/$path.")
end
cache = getcachedir(source)
path2 = joinpath(cache,escape(path))
path2 = joinpath(cache, match(r"[^/]+$",path).match)
Copy link

@omus omus Feb 6, 2018

Choose a reason for hiding this comment

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

I found that using a simple regex match to pick off the filename solved my problems.

The match should probably be replaced with basename

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did not know about that function! That seems to do the trick just fine.

The `basename` function does what the previous regex match did, so use that instead.
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.

3 participants