Retry file conversion in case of DB connection issues
Fix CODEOCEAN-RZ
This commit is contained in:
@ -4,6 +4,7 @@ module FileConversion
|
|||||||
private
|
private
|
||||||
|
|
||||||
def convert_files_json_to_files(files_json)
|
def convert_files_json_to_files(files_json)
|
||||||
|
retry_block do
|
||||||
# Return an empty list of files and directories if the files_json is nil
|
# Return an empty list of files and directories if the files_json is nil
|
||||||
return [[], []] if files_json.blank?
|
return [[], []] if files_json.blank?
|
||||||
|
|
||||||
@ -38,8 +39,18 @@ module FileConversion
|
|||||||
end
|
end
|
||||||
[augment_files_for_download(files), directories]
|
[augment_files_for_download(files), directories]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def augment_files_for_download(files)
|
def augment_files_for_download(files)
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def retry_block(count: 1)
|
||||||
|
yield
|
||||||
|
rescue ActiveRecord::StatementInvalid => e
|
||||||
|
count -= 1
|
||||||
|
retry if count.positive?
|
||||||
|
|
||||||
|
raise e
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user