Skip to content

Commit

Permalink
πŸ—‚ Fix non-extension file names
Browse files Browse the repository at this point in the history
  • Loading branch information
murat committed Aug 30, 2017
1 parent 59ce483 commit 0317747
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
# rspec failure tracking
.rspec_status

/.idea
/.idea
/*.gem
13 changes: 9 additions & 4 deletions lib/tors/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def download(choice)
else
begin
source = Net::HTTP.get(URI.parse(choice[:url]))
target_file_name = choice[:name] + '.torrent'
target_file = File.join(@directory, choice[:name])
target_file_name = choice[:name].tr("\n", ' ').squeeze(' ').strip + '.torrent'
target_file = File.join(@directory, target_file_name)
puts 'Downloading ' + target_file_name
File.write(target_file, source)
rescue IOError => e
Expand All @@ -120,8 +120,13 @@ def threat_defence(page)
private

def check_download_directory
raise "Your download directory #{@directory} not found." unless File.exist? @directory or File.directory? @directory
raise "Your download directory #{@directory} not writable." unless File.writable? @directory
ioerr = false
ioerr = "😱 Your download directory #{@directory} not found." unless File.exist? @directory or File.directory? @directory
ioerr = "😱 Your download directory #{@directory} not writable." unless File.writable? @directory
if ioerr
puts ioerr
Process.kill 9, Process.pid
end
end
end
end

0 comments on commit 0317747

Please sign in to comment.