Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

flashers: fix handling of local file#371

Merged
mangelajo merged 1 commit intojumpstarter-dev:mainfrom
bennyz:fix-local-file
Mar 24, 2025
Merged

flashers: fix handling of local file#371
mangelajo merged 1 commit intojumpstarter-dev:mainfrom
bennyz:fix-local-file

Conversation

@bennyz
Copy link
Copy Markdown
Member

@bennyz bennyz commented Mar 23, 2025

Summary by CodeRabbit

  • Refactor
    • Enhanced consistency in file handling during background image transfer operations, resulting in clearer and more uniform status reporting.

Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
@bennyz bennyz requested a review from mangelajo March 23, 2025 15:06
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 23, 2025

Walkthrough

The change refactors the _transfer_bg_thread method in the client module. A new variable, filename, is introduced to store the extracted file name from src_path. The variable is then used consistently in conditional checks for image existence, metadata file construction, and logging. No public API changes were made.

Changes

File Path Change Summary
packages/.../client.py Refactored _transfer_bg_thread to use a new filename variable (extracted from src_path), updating image existence checks, metadata naming, and logs.

Poem

I’m a little rabbit in a code-filled land,
Hopping through logs with a steady hand.
filename now leads the way,
With clear checks that brighten the day.
Hoppity changes make coding grand!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c7d55b7 and f790a5d.

📒 Files selected for processing (1)
  • packages/jumpstarter-driver-flashers/jumpstarter_driver_flashers/client.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: e2e
  • GitHub Check: pytest-matrix (3.13)
  • GitHub Check: pytest-matrix (3.12)
  • GitHub Check: pytest-matrix (3.11)
🔇 Additional comments (7)
packages/jumpstarter-driver-flashers/jumpstarter_driver_flashers/client.py (7)

252-253: Good refactoring to extract the filename handling logic.

This change improves the code by consistently extracting the filename from src_path once, handling both string/PathLike objects and other types. This makes the code more maintainable and prevents potential inconsistencies when dealing with different path types.


257-259: LGTM - Consistent use of the extracted filename variable.

The code now consistently uses the extracted filename variable instead of directly accessing src_path.name, which ensures proper handling of both local and remote file paths.


262-266: Good improvement for remote file handling.

The code now uses the extracted filename variable consistently for remote files as well, making the code more robust when dealing with different path types.


270-270: LGTM - Consistent filename usage for metadata.

Using the extracted filename variable for constructing the metadata file name ensures consistency with the rest of the method.


272-277: LGTM - Consistent filename usage in metadata checks.

The code now consistently uses the extracted filename variable in the conditions for checking metadata file existence and in stat operations.


280-280: LGTM - Consistent filename usage in write operation.

The code now uses the extracted filename variable in the write operation, ensuring consistency with the rest of the method.


283-283: LGTM - Consistent filename usage in logging.

The code now uses the extracted filename variable in the logging statement, ensuring consistency with the rest of the method.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 23, 2025

Deploy Preview for jumpstarter-docs ready!

Name Link
🔨 Latest commit f790a5d
🔍 Latest deploy log https://app.netlify.com/sites/jumpstarter-docs/deploys/67e0236fb34a7b0008ca6a77
😎 Deploy Preview https://deploy-preview-371--jumpstarter-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

file_hash = self._sha256_file(src_operator, src_path)
if to_storage.hash(src_path.name) == file_hash:
self.logger.info(f"Image {src_path} already exists in storage with matching hash, skipping")
if to_storage.exists(filename) and to_storage.hash(filename) == file_hash:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh , good catch!

I probably tried it with a file I already had uploaded previously.


# last attempt to check if the image in storage matches the known metadata
metadata, metadata_json = self._create_metadata_and_json(src_operator, src_path)
metadata_file = src_path.name + ".metadata"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to work on moving all this logic to the opendal storage driver directly :D

Copy link
Copy Markdown
Member

@mangelajo mangelajo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you benny!

@mangelajo mangelajo merged commit 892b71a into jumpstarter-dev:main Mar 24, 2025
14 checks passed
@bennyz bennyz deleted the fix-local-file branch March 24, 2025 09:59
@mangelajo mangelajo added this to the 0.6.0 milestone May 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants