From 2313538e6bed0d86d483d45f53b3c2f5884a998c Mon Sep 17 00:00:00 2001 From: Rongrong Date: Tue, 5 Nov 2024 02:54:24 +0800 Subject: [PATCH] fix(`/sub`): monitoring not deferred as per server-side cache Since d6aa15ce, monitoring tasks will be deferred when aggressive server-side caches (e.g., Cloudflare and RSSHub, which make it futile to check for updates before cache expiration) are detected. However, the first monitoring task for a newly subscribed feed was not being deferred. This has been fixed and the first monitoring task now waits for the server-side cache to expire. Signed-off-by: Rongrong --- docs/CHANGELOG.md | 2 ++ docs/CHANGELOG.zh.md | 2 ++ src/command/inner/sub.py | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 8ee66e8c44..9b4863e686 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -5,10 +5,12 @@ ### Enhancements - **No longer proxies images from `*.wp.com` when generating Telegraph posts**: `*.wp.com` is in the blocklist of `wsrv.nl` (environment variable `IMAGES_WESERV_NL`). Thus, these images are no longer proxied when generating Telegraph posts. All images from `*.wp.com` can be accessed with any referer header, so they are now kept as is. +- **Minor refactor**: Some internal functions have been refactored to improve performance, readability and maintainability. ### Bug fixes - **Canonical `DATABASE_URL` not recognized**: Since v2.9.0, `DATABASE_URL` is canonicalized before connecting to the corresponding database. However, a canonical URL pointing to a local path cannot be recognized when checking the validity of the scheme (database type). Both canonical (`scheme:/path/to/file.db`) and traditional (`scheme:///path/to/file.db`) forms of such URLs are recognized correctly now. +- **Monitoring not deferred as per server-side cache when subscribing**: Since v2.7.0, monitoring tasks will be deferred when aggressive server-side caches (e.g., Cloudflare and RSSHub, which make it futile to check for updates before cache expiration) are detected. However, the first monitoring task for a newly subscribed feed was not being deferred. This has been fixed and the first monitoring task now waits for the server-side cache to expire. ## v2.9.0: Telegraph-related revert, skip cert verification, and more diff --git a/docs/CHANGELOG.zh.md b/docs/CHANGELOG.zh.md index 12a639896c..3e1f400391 100644 --- a/docs/CHANGELOG.zh.md +++ b/docs/CHANGELOG.zh.md @@ -5,10 +5,12 @@ ### 增强 - **生成 Telegraph 文章时,不再代理来自 `*.wp.com` 的图像**: `*.wp.com` 位于 `wsrv.nl` (环境变量 `IMAGES_WESERV_NL`) 的阻断列表中。因此,在生成 Telegraph 文章时,这些图像不再被代理。来自 `*.wp.com` 的所有图片都可以用任何 refer 头访问,因此它们现在保持原样。 +- **次要的重构**: 重构了一些内部函数以提高性能、可读性和可维护性。 ### Bug 修复 - **无法识别规范的 `DATABASE_URL`**: 自 v2.9.0 起, 在连接到相应的数据库之前,`DATABASE_URL` 被规范化。然而,在检查 scheme (数据库类型) 的合法性时,无法识别指向本地路径的规范 URL。现在,此类 URL 的规范 (`scheme:/path/to/file.db`) 和传统 (`scheme:///path/to/file.db`) 形式都被正确识别。 +- **订阅时不会根据服务端缓存延迟监控**:自 v2.7.0 起,当检测到激进的服务器端缓存时,监控任务将被延迟(例如 Cloudflare 和 RSSHub,它们使得在缓存过期之前检查更新变得徒劳无功)。但是,当新订阅 feed 时,第一个监视任务不会被推迟。该问题已修复,第一个监控任务会等待服务端缓存过期。 ## v2.9.0: 与 Telegraph 相关的 revert、跳过证书校验和更多 diff --git a/src/command/inner/sub.py b/src/command/inner/sub.py index f9fb9bbe76..aa271e8508 100644 --- a/src/command/inner/sub.py +++ b/src/command/inner/sub.py @@ -99,7 +99,7 @@ async def sub(user_id: int, if created_new_feed or feed.state == 0: feed.state = 1 feed.error_count = 0 - feed.next_check_time = None + feed.next_check_time = wf.calc_next_check_as_per_server_side_cache() etag = wr.etag if etag: feed.etag = etag