Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate core logic of importchannel to a utility function and update associated tasks #13099

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

thesujai
Copy link
Contributor

Summary

This refactors the importchannel command and its related tasks

  1. Moved the channel transfer logic to a utility function(Which originally was inside the management function)
  2. Updated the channel import tasks to use the utility function instead of calling the importchannel command
  3. Moved import_channel_by_id to channel_import.py util where the function is suited to be

References

Fixes #13095
Subtask of #9266

Reviewer guidance

NA

@github-actions github-actions bot added the DEV: backend Python, databases, networking, filesystem... label Feb 20, 2025
@@ -587,15 +581,11 @@ def diskimport(
drive = get_mounted_drive_by_id(drive_id)
Copy link
Contributor Author

@thesujai thesujai Feb 20, 2025

Choose a reason for hiding this comment

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

This line is duplicated at line 594. Is it a bug or is there any purpose for this?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's a bug, but it definitely looks unnecessary the second time. Probably just copy pasted from somewhere else.

logger = logging.getLogger(__name__)


def start_file_transfer(job, filetransfer, channel_id, dest, no_upgrade, contentfolder):
Copy link
Member

@rtibbles rtibbles Feb 20, 2025

Choose a reason for hiding this comment

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

For both of these functions, I would like it if we did not pass in job as a first argument, and instead invoked get_current_job inside the function itself.

What you would then need is a dummy job in the case where the function is not running in a task runner context, that just does a noop for all the methods of the job class (this way you don't need to keep on checking if the job exists or not).

@rtibbles
Copy link
Member

This makes sense so far, I'd want the test updated, and not just skipped, before we merge, and I think not passing in the job into the functions is preferable - because that will eventually allow us to phase out the AsyncCommand class (passing the self into the function as the job is depending on methods defined on the AsyncCommand).

@thesujai
Copy link
Contributor Author

Thank you @rtibbles . I will update it by tomorrow:)

@thesujai
Copy link
Contributor Author

Updated the utils functions as well as importchannel tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Core logic for the importchannel command is migrated to utility functions and all associated tasks updated
2 participants