Skip to content

Commit

Permalink
Merge branch 'fix/io_timeouterror' into pagination_with_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rogenobl committed Jan 31, 2024
2 parents 8868e23 + 78930aa commit 1de23e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/command/update/general_lastup_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def update_other_novels
"general_lastup" => downloader.get_general_lastup,
"length" => downloader.novel_length
}
rescue OpenURI::HTTPError, Errno::ECONNRESET, Errno::ETIMEDOUT, Net::OpenTimeout
rescue OpenURI::HTTPError, Errno::ECONNRESET, Errno::ETIMEDOUT, Net::OpenTimeout, IO::TimeoutError
next
end
data = @database[id]
Expand Down
5 changes: 3 additions & 2 deletions lib/downloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Downloader

class InvalidTarget < StandardError; end
class SuspendDownload < StandardError; end
class IO::TimeoutError; end # for 3.1 or earlier

def initialize(target, options = {})
id = Downloader.get_id_by_target(target)
Expand Down Expand Up @@ -800,7 +801,7 @@ def get_latest_table_of_contents(old_toc, through_error: false)
"subtitles" => subtitles
}
toc_objects
rescue OpenURI::HTTPError, Errno::ECONNRESET, Errno::ETIMEDOUT, Net::OpenTimeout => e
rescue OpenURI::HTTPError, Errno::ECONNRESET, Errno::ETIMEDOUT, Net::OpenTimeout, IO::TimeoutError => e
raise if through_error # エラー処理はしなくていいからそのまま例外を受け取りたい時用
if e.message.include?("404")
@stream.error "小説が削除されているか非公開な可能性があります"
Expand Down Expand Up @@ -1173,7 +1174,7 @@ def download_raw_data(url)
URI.open(url, "r:#{@setting["encoding"]}", open_uri_options) do |fp|
raw = Helper.pretreatment_source(fp.read, @setting["encoding"])
end
rescue OpenURI::HTTPError, Errno::ECONNRESET, Errno::ETIMEDOUT, Net::OpenTimeout => e
rescue OpenURI::HTTPError, Errno::ECONNRESET, Errno::ETIMEDOUT, Net::OpenTimeout, IO::TimeoutError => e
case e.message
when /^503/
# 503 はアクセス規制やメンテ等でリトライしてもほぼ意味がないことが多いため一度で諦める
Expand Down

0 comments on commit 1de23e3

Please sign in to comment.