Skip to content

Commit

Permalink
use explicit open/close for Document.parse_stream to avoid Windows's …
Browse files Browse the repository at this point in the history
…behavior.
  • Loading branch information
kmuto committed Feb 20, 2018
1 parent 15a0119 commit 060592e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/review/epubmaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,7 @@ def produce(yamlfile, bookname = nil)
@producer.produce("#{bookname}.epub", basetmpdir, epubtmpdir)
log('Finished.')
ensure
unless @config['debug']
FileUtils.remove_entry_secure(basetmpdir, true)
# XXX: workaround strange behavior in Windows
FileUtils.remove_entry_secure(basetmpdir) if File.exist?(basetmpdir)
end
FileUtils.remove_entry_secure(basetmpdir) unless @config['debug']
end
end

Expand Down Expand Up @@ -368,7 +364,8 @@ def detect_properties(path)
def write_info_body(basetmpdir, _id, filename, ispart = nil, chaptype = nil)
headlines = []
path = File.join(basetmpdir, filename)
Document.parse_stream(File.new(path), ReVIEWHeaderListener.new(headlines))
htmlio = File.new(path)
Document.parse_stream(htmlio, ReVIEWHeaderListener.new(headlines))
properties = detect_properties(path)
prop_str = ''
prop_str = ',properties=' + properties.join(' ') if properties.present?
Expand All @@ -382,6 +379,7 @@ def write_info_body(basetmpdir, _id, filename, ispart = nil, chaptype = nil)
first = nil
end
end
htmlio.close
end

def push_contents(_basetmpdir)
Expand Down

0 comments on commit 060592e

Please sign in to comment.