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

"Permissions denied" when downloading iso #2

Closed
whren opened this issue Apr 13, 2012 · 2 comments
Closed

"Permissions denied" when downloading iso #2

whren opened this issue Apr 13, 2012 · 2 comments
Assignees
Labels

Comments

@whren
Copy link
Owner

whren commented Apr 13, 2012

"permission denied" for fileutils's mv/rename in the download_iso function.
This is due to the source not closed, and windows keep an handle opened on the iso.

@ghost ghost assigned whren Apr 13, 2012
@whren
Copy link
Owner Author

whren commented Apr 15, 2012

I need to add a src.close before the FileUtils.mv() so the http stream is cleanly closed and handle removed.
Not doing this on windows let a blocking handle on the stream, raising a 'Permission Denied' on the FileUtils.mv().

You can reproduce this issue with the following ruby code :

require 'progressbar'
require 'open-uri'
require 'fileutils'

pbar = nil
URI.parse("http://ftp.belnet.be/packages/damnsmalllinux/archive/bootfloppy-1.5.img").open(
  :content_length_proc => lambda {|t|
  if t && 0 < t
    pbar = ProgressBar.new("Fetching file", t)
    pbar.file_transfer_mode
  end
  },
  :progress_proc => lambda {|s|
    pbar.set s if pbar
  }) { |src|
  FileUtils.mv(src.path,"d:/test-temp.img")
}

=> Raise the following error : Errno::EACCES: Permission denied - (C:/Users/XXXX/AppData/Local/Temp/open-uri20120415-26192-xpsi62, d:/test-temp.img)

And confirm the resolution of the issue with the following (note the add of src.close) :

require 'progressbar'
require 'open-uri'
require 'fileutils'

pbar = nil
URI.parse("http://ftp.belnet.be/packages/damnsmalllinux/archive/bootfloppy-1.5.img").open(
  :content_length_proc => lambda {|t|
  if t && 0 < t
    pbar = ProgressBar.new("Fetching file", t)
    pbar.file_transfer_mode
  end
  },
  :progress_proc => lambda {|s|
    pbar.set s if pbar
  }) { |src|
  src.close
  FileUtils.mv(src.path,"d:/test-temp.img")
}

@whren
Copy link
Owner Author

whren commented Apr 15, 2012

See 6df40d6

@whren whren closed this as completed Apr 15, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant