Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Preserve filename extensions to prevent AtomicParsley from segfaulting.

  • Loading branch information...
commit 498ad0abdb5dbe42c9a72bafd17ece6474fac7d9 1 parent 8939b6c
@olly authored
Showing with 6 additions and 3 deletions.
  1. +2 −1  lib/AtomicTV.rb
  2. +4 −2 lib/AtomicTV/episode_metadata.rb
View
3  lib/AtomicTV.rb
@@ -1,6 +1,7 @@
+require 'fileutils'
require 'open-uri'
require 'pathname'
-require 'tempfile'
+require 'tmpdir'
require 'plist'
require 'tvdb_party'
View
6 lib/AtomicTV/episode_metadata.rb
@@ -80,9 +80,11 @@ def writers
attr_reader :posters
def with_loaded_posters
+ temporary_directory = Dir.mktmpdir
+
@posters = series.season_posters(episode.season_number, 'en').map do |poster|
url = ArtworkBaseURL + poster.path
- file = Tempfile.new('AtomicTV')
+ file = File.new(File.join(temporary_directory, File.basename(url)), 'w')
file.write(open(url).read)
file.close
file
@@ -91,7 +93,7 @@ def with_loaded_posters
yield
ensure
- @posters.each {|file| file.unlink}
+ FileUtils.rm_rf(temporary_directory)
@posters = nil
end
Please sign in to comment.
Something went wrong with that request. Please try again.