Skip to content

Commit

Permalink
RHELMISC-7213: Fix share folder handle_exceptions
Browse files Browse the repository at this point in the history
Fix retry behavior in handle_exceptions when share_folder fails.
Previously, when share_folder failed, handle_exceptions would retry
the entire block, attempting to create an already existing folder.
This led to unnecessary retries and potential errors.

Now the operations are separated:
- Folder creation has its own exception handling block
- Share folder and link generation are handled separately
- Prevents redundant folder creation attempts during retries

This ensures cleaner retry logic and proper error handling for
each operation independently.

Signed-off-by: Vitalii Chulak <[email protected]>
  • Loading branch information
Jedoku committed Feb 23, 2025
1 parent 44977e5 commit 6797944
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/resultuploaders/dropbox/dropbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def connect
def create_project_folder
handle_exceptions(__method__) do
@path = "/#{@repo}/CI/#{@tag}-#{@timestamp}"
@dropbox.create_folder(@path)
@dropbox.create_folder(@path) unless folder_exists?(@path)
@dropbox.share_folder(@path)
@url = "#{@dropbox.create_shared_link_with_settings(@path).url}&lst="
@logger.info("Dropbox project folder created: #{@url}")
Expand Down Expand Up @@ -153,6 +153,12 @@ def delete_file(r_name)
end
end

def folder_exists?(folder_path)
@dropbox.get_metadata(folder_path).is_a?(DropboxApi::Metadata::Folder)
rescue DropboxApi::Errors::NotFoundError
false
end

def close; end
end
end

0 comments on commit 6797944

Please sign in to comment.