Skip to content

Commit

Permalink
🍻 fix retry
Browse files Browse the repository at this point in the history
  • Loading branch information
r74tech committed Oct 8, 2024
1 parent 914bc23 commit 5624b09
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions wikidotrb/lib/wikidotrb/module/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -569,13 +569,27 @@ def self.create_or_edit(site:, fullname:, page_id: nil, title: "", source: "", c
)
end

res = PageCollection.search_pages(site, SearchPagesQuery.new(fullname: fullname))
puts "Search result: #{res.inspect}"
raise Wikidotrb::Common::Exceptions::NotFoundException, "Page creation failed: #{fullname}" if res.empty?
retries = site.config.attempt_limit || 3
retry_interval = site.config.retry_interval || 5

begin
res = PageCollection.search_pages(site, SearchPagesQuery.new(fullname: fullname))
puts "Search result: #{res.inspect}"
raise Wikidotrb::Common::Exceptions::NotFoundException, "Page creation failed: #{fullname}" if res.empty?
rescue Wikidotrb::Common::Exceptions::NotFoundException => e
retries -= 1
if retries > 0
sleep retry_interval
retry
else
raise e
end
end

res[0]
end


def edit(title: nil, source: nil, comment: nil, force_edit: false)
title ||= @title
source ||= @source.wiki_text
Expand Down

0 comments on commit 5624b09

Please sign in to comment.