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

file urls do not work on windows #78

Closed
logicminds opened this issue Oct 22, 2015 · 2 comments
Closed

file urls do not work on windows #78

logicminds opened this issue Oct 22, 2015 · 2 comments

Comments

@logicminds
Copy link
Contributor

Because windows has to be different...

The URI ruby library does not work as expected on windows because of the fact there is no root drive. So files fail to download because the urls are interpreted incorrectly.

Example:

irb(main):006:0> URI('file://d:/OSS/one/two/three.zip').path
=> "/OSS/one/two/three.zip"

And adding another slash produces another issue

irb(main):007:0> URI('file:///d:/OSS/one/two/three.zip').path
=> "/d:/OSS/one/two/three.zip"

This should be d:/OSS/one/two/three.zip

@logicminds
Copy link
Contributor Author

I have this working on my own fork with the following:

class FILE
      def initialize(_url, _options)
      end

      def normalize_path(uri)
        # URI for windows does not work as expected and returns a path without the root drive
        # this attempts to fix that
        if /^file:\/{2}([a-z,A-Z]?)/.match(uri.to_s)   # file://c:/one/two/three.zip
          uri.to_s.gsub(/^file:\/{2}([a-z,A-Z])?/, "#{$1}:")
        else
          uri.path
        end
      end

      def download(uri, file_path)
        src_path = normalize_path(uri)
        FileUtils.copy(src_path, file_path)
      end
    end

If this is acceptable I can make a PR.

@nanliu
Copy link
Contributor

nanliu commented Oct 23, 2015

file:///d:/OSS/one/two/three.zip is technically correct, because I think file://d:/OSS/one/two/three.zip, would be host = d:, path = OSS, and this patch is implementing the wrong behavior (puppet:/// and not puppet:// because puppet://{server}/). So maybe implementing #77 is the better approach, because this is not intuitive for Windows.

nanliu added a commit to nanliu/puppet-archive that referenced this issue Feb 25, 2016
* Fix local files for non faraday providers
* Fix voxpupuliGH-77 allows local files to be specified without using file:///
* Fix voxpupuliGH-78 allow local file:///c:/... on windows
nanliu added a commit to nanliu/puppet-archive that referenced this issue Feb 25, 2016
* Fix local files for non faraday providers
* Fix voxpupuliGH-77 allows local files to be specified without using file:///
* Fix voxpupuliGH-78 allow local file:///c:/... on windows
nanliu added a commit to nanliu/puppet-archive that referenced this issue Feb 25, 2016
* Fix local files for non faraday providers
* Fix voxpupuliGH-77 allows local files to be specified without using file:///
* Fix voxpupuliGH-78 allow local file:///c:/... on windows
cegeka-jenkins pushed a commit to cegeka/puppet-archive that referenced this issue Oct 23, 2017
* Fix local files for non faraday providers
* Fix voxpupuliGH-77 allows local files to be specified without using file:///
* Fix voxpupuliGH-78 allow local file:///c:/... on windows
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

No branches or pull requests

2 participants