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

修复 Transmission 暂停-重启错误 + 废弃 Transmission 适配器 #381

Merged
merged 6 commits into from
Aug 26, 2024

Conversation

Ghost-chu
Copy link
Collaborator

@Ghost-chu Ghost-chu commented Aug 25, 2024

修复了 Transmission 暂停-重启的 BUG,并开始推进废弃 Transmission 适配器。

#382

后端更改

  • Transmission 适配器错误修复
  • 向前端持续发送 Transmission 将会启用的提示信息,将下载器标记为 “需要采取行动”
  • 阻止用户通过 WebUI 更改已存在的 Transmission 配置段,除非添加 -Dpbh.downloader.transmission.i-know-transmission-is-discourage-and-could-be-removed-in-future-please-dont-show-require-take-actions-status-text-and-i-know-what-i-am-doing JVM 附加参数

前端更改

OOBE

image

Dashboard

image

image

Summary by CodeRabbit

  • New Features

    • Introduced a locking mechanism for the banWave method to enhance concurrency control.
    • Added a default method runScheduleTasks() to the Downloader interface for improved modularity.
    • Implemented a mechanism for managing paused torrents in the Transmission class using a delay queue.
    • Expanded localization support with new warning messages regarding the deprecated Transmission adapter.
  • User Interface Changes

    • Disabled the "Transmission" option in downloader configuration with a tooltip for user guidance.

Copy link
Contributor

coderabbitai bot commented Aug 25, 2024

Walkthrough

The recent changes implement a locking mechanism in the banWave method of PeerBanHelperServer to improve concurrency control. The Downloader interface now includes a default scheduling method, while the Transmission class has been updated to manage paused torrents using a DelayQueue. Additional localization updates provide warnings against using the deprecated Transmission adapter, enhancing overall system functionality.

Changes

Files Change Summary
src/main/java/com/ghostchu/peerbanhelper/PeerBanHelperServer.java Added a ReentrantLock to the banWave method for concurrency control, including error handling for interruptions and ensuring thread-safe execution of ban wave logic.
src/main/java/com/ghostchu/peerbanhelper/downloader/Downloader.java Introduced a default method runScheduleTasks() in the Downloader interface to enhance modularity.
src/main/java/com/ghostchu/peerbanhelper/downloader/impl/transmission/Transmission.java Implemented a DelayQueue for managing paused torrents, replacing synchronous sleep with asynchronous handling. Updated relaunchTorrents to utilize this queue, and added a new static inner class DelayedTorrents.
src/main/java/com/ghostchu/peerbanhelper/text/Lang.java Added a new enum constant DOWNLOADER_TRANSMISSION_DISCOURAGE for localization purposes.
src/main/resources/lang/en_us/messages.yml Introduced a new warning message DOWNLOADER_TRANSMISSION_DISCOURAGE regarding the use of the Transmission adapter.
src/main/resources/lang/messages_fallback.yml Added a new warning message about the deprecation of the Transmission adapter.
src/main/resources/lang/zh_cn/messages.yml Added a new warning message about the deprecated status of the Transmission adapter in Chinese.
webui/src/views/dashboard/components/editDownloaderModal.vue Disabled the "Transmission" radio button and wrapped it in a tooltip to discourage selection.
webui/src/views/dashboard/locale/en-US.ts Added a new warning message for the dashboard about the use of the Transmission adapter.
webui/src/views/dashboard/locale/zh-CN.ts Added a new warning message about the deprecated status of the Transmission adapter in Chinese.
webui/src/views/oobe/components/addDownloader.vue Wrapped the "Transmission" radio button in a tooltip and disabled it to discourage its selection.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PeerBanHelperServer
    participant Downloader
    participant Transmission

    User->>PeerBanHelperServer: Trigger banWave()
    PeerBanHelperServer->>PeerBanHelperServer: Acquire banWaveLock
    PeerBanHelperServer->>Downloader: runScheduleTasks()
    Downloader->>Transmission: Update paused torrents
    Transmission->>Transmission: Manage torrent states
    PeerBanHelperServer->>PeerBanHelperServer: Release banWaveLock
Loading

🐇 In the burrow, changes take flight,
With locks and queues, all feels just right.
Tasks run smoothly, torrents align,
In this new code, everything shines!
Hops of joy, let the magic unfold,
For each little change is a story told! 🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@Ghost-chu Ghost-chu marked this pull request as draft August 25, 2024 14:56
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2d3b3bc and 256b27a.

Files selected for processing (3)
  • src/main/java/com/ghostchu/peerbanhelper/PeerBanHelperServer.java (4 hunks)
  • src/main/java/com/ghostchu/peerbanhelper/downloader/Downloader.java (1 hunks)
  • src/main/java/com/ghostchu/peerbanhelper/downloader/impl/transmission/Transmission.java (5 hunks)
Additional comments not posted (5)
src/main/java/com/ghostchu/peerbanhelper/downloader/Downloader.java (1)

55-59: Approved: Addition of the default method runScheduleTasks() in the Downloader interface.

This change enhances modularity by providing a default implementation that can be overridden by implementing classes if needed.

src/main/java/com/ghostchu/peerbanhelper/downloader/impl/transmission/Transmission.java (3)

48-48: Approved: Introduction of DelayQueue<DelayedTorrents> for managing paused torrents.

This change enhances the control flow by enabling asynchronous handling of torrent resumption, which is more efficient than the previous synchronous sleep mechanism.


231-250: Approved: Implementation of the DelayedTorrents class.

This class is well implemented to work with DelayQueue by providing necessary methods to manage delay times and compare instances based on their scheduled start time.


220-222: Approved: Modification of runScheduleTasks() to invoke unpauseTorrents(false).

This ensures that any scheduled tasks are processed appropriately, aligning with the changes made to manage paused torrents.

src/main/java/com/ghostchu/peerbanhelper/PeerBanHelperServer.java (1)

103-103: Approved: Introduction of ReentrantLock for managing concurrency in banWave method.

This change improves the robustness of the method by preventing race conditions and ensuring that the method can handle interruptions gracefully.

Copy link

cloudflare-workers-and-pages bot commented Aug 25, 2024

Deploying pbh-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 63581fc
Status: ✅  Deploy successful!
Preview URL: https://04376bee.peerbanhelper.pages.dev
Branch Preview URL: https://fixtransmissiontaskrestore.peerbanhelper.pages.dev

View logs

@Ghost-chu Ghost-chu changed the title 修复 Transmission 暂停-重启错误 修复 Transmission 暂停-重启错误 + 废弃 Transmission 适配器 Aug 25, 2024
@Ghost-chu Ghost-chu marked this pull request as ready for review August 25, 2024 16:18
@Ghost-chu Ghost-chu requested a review from a team as a code owner August 25, 2024 16:18
@Ghost-chu Ghost-chu requested a review from a team August 25, 2024 16:21
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 256b27a and 5252ce2.

Files selected for processing (9)
  • src/main/java/com/ghostchu/peerbanhelper/downloader/impl/transmission/Transmission.java (7 hunks)
  • src/main/java/com/ghostchu/peerbanhelper/text/Lang.java (1 hunks)
  • src/main/resources/lang/en_us/messages.yml (1 hunks)
  • src/main/resources/lang/messages_fallback.yml (1 hunks)
  • src/main/resources/lang/zh_cn/messages.yml (1 hunks)
  • webui/src/views/dashboard/components/editDownloaderModal.vue (2 hunks)
  • webui/src/views/dashboard/locale/en-US.ts (1 hunks)
  • webui/src/views/dashboard/locale/zh-CN.ts (1 hunks)
  • webui/src/views/oobe/components/addDownloader.vue (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/ghostchu/peerbanhelper/downloader/impl/transmission/Transmission.java
Additional context used
yamllint
src/main/resources/lang/zh_cn/messages.yml

[error] 366-366: no new line character at the end of file

(new-line-at-end-of-file)

src/main/resources/lang/messages_fallback.yml

[error] 367-367: no new line character at the end of file

(new-line-at-end-of-file)

src/main/resources/lang/en_us/messages.yml

[error] 367-367: no new line character at the end of file

(new-line-at-end-of-file)

Additional comments not posted (11)
webui/src/views/oobe/components/addDownloader.vue (2)

15-17: Approve the discouragement of Transmission usage.

The addition of the tooltip and the disabling of the Transmission option are in line with the PR objectives to phase out the Transmission adapter. This change effectively communicates the discouraged status to users.


44-50: Approve the reformatting of import statements.

The reformatting of the import statements improves code consistency and readability without affecting functionality.

webui/src/views/dashboard/locale/zh-CN.ts (1)

51-51: Approve the addition of the warning message.

The new warning message under 'page.dashboard.editModal.transmission.discourage' is clear and informative, effectively enhancing user awareness about the deprecation of the Transmission adapter.

webui/src/views/dashboard/components/editDownloaderModal.vue (2)

16-18: Approve the discouragement of Transmission usage in the edit modal.

Similar to the OOBE component, the addition of the tooltip and the disabling of the Transmission option in the edit modal are well-aligned with the PR objectives to phase out the Transmission adapter.


45-50: Approve the reformatting of import statements.

The reformatting of the import statements in this file, similar to the OOBE component, improves code consistency and readability without affecting functionality.

webui/src/views/dashboard/locale/en-US.ts (1)

50-50: Approved: New warning message added.

The new localization string effectively communicates the risks associated with the frequent use of the Transmission Adapter, aligning with the PR's objectives to discourage its use.

src/main/java/com/ghostchu/peerbanhelper/text/Lang.java (1)

329-329: Approved: New enum entry added.

The addition of DOWNLOADER_TRANSMISSION_DISCOURAGE to the Lang enum is consistent with the application's localization practices and supports the new warning message functionality.

src/main/resources/lang/messages_fallback.yml (2)

365-366: Ensure proper formatting for IN_ECOMODE_DESCRIPTION.

The modification to IN_ECOMODE_DESCRIPTION retains the existing content but enhances formatting. Ensure that the formatting changes align with the intended display standards and do not introduce any parsing issues.


367-367: New entry added for DOWNLOADER_TRANSMISSION_DISCOURAGE.

The added message effectively communicates the discouragement of using the Transmission adapter due to potential risks. This aligns with the PR's objectives of enhancing user awareness regarding the deprecated functionality.

Tools
yamllint

[error] 367-367: no new line character at the end of file

(new-line-at-end-of-file)

src/main/resources/lang/en_us/messages.yml (2)

365-366: Ensure proper formatting for IN_ECOMODE_DESCRIPTION.

The modification to IN_ECOMODE_DESCRIPTION retains the existing content but enhances formatting. Ensure that the formatting changes align with the intended display standards and do not introduce any parsing issues.


367-367: New entry added for DOWNLOADER_TRANSMISSION_DISCOURAGE.

The added message effectively communicates the discouragement of using the Transmission adapter due to potential risks. This aligns with the PR's objectives of enhancing user awareness regarding the deprecated functionality.

Tools
yamllint

[error] 367-367: no new line character at the end of file

(new-line-at-end-of-file)

src/main/resources/lang/zh_cn/messages.yml Show resolved Hide resolved
src/main/resources/lang/messages_fallback.yml Show resolved Hide resolved
src/main/resources/lang/en_us/messages.yml Show resolved Hide resolved
@@ -12,7 +12,9 @@
<a-form-item field="config.type" :label="t('page.dashboard.editModal.label.type')" required>
<a-radio-group v-model="config.downloaderConfig.config.type" type="button">
<a-radio :value="ClientTypeEnum.qBittorrent">qBittorrent</a-radio>
<a-radio :value="ClientTypeEnum.Transmission">Transmission</a-radio>
<a-tooltip :content="t('page.dashboard.editModal.transmission.discourage')">
Copy link
Collaborator

Choose a reason for hiding this comment

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

添加了flag之后可以启用tr,这个体现在哪儿呢

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

新添加总是不允许的,但此 flag 允许用户恢复 testDownloader 的返回结果,这样可以让 WebUI 保存配置更改。并可以隐藏烦人的 “需要采取行动” 提示。

Copy link
Collaborator

Choose a reason for hiding this comment

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

新添加的话,自己去改配置文件吧

@Ghost-chu Ghost-chu requested a review from paulzzh August 26, 2024 06:50
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5252ce2 and e44e5ff.

Files selected for processing (1)
  • src/main/java/com/ghostchu/peerbanhelper/downloader/impl/transmission/Transmission.java (7 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/ghostchu/peerbanhelper/downloader/impl/transmission/Transmission.java

@Gaojianli Gaojianli self-requested a review August 26, 2024 10:49
@Gaojianli Gaojianli merged commit a936d60 into master Aug 26, 2024
6 checks passed
@Gaojianli Gaojianli deleted the fixTransmissionTaskRestore branch August 26, 2024 10:57
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e44e5ff and 63581fc.

Files selected for processing (2)
  • webui/src/views/dashboard/locale/en-US.ts (1 hunks)
  • webui/src/views/dashboard/locale/zh-CN.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • webui/src/views/dashboard/locale/en-US.ts
Additional comments not posted (1)
webui/src/views/dashboard/locale/zh-CN.ts (1)

50-50: LGTM!

The added localization string is clear and informative. It effectively communicates the deprecation of the Transmission adapter and the associated risks.

The code changes are approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants