mirror of
https://github.com/RubyMetric/chsrc
synced 2026-02-27 17:41:18 +08:00
Add set by postfix
This commit is contained in:
@@ -829,42 +829,6 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief 填充专用测速链接
|
||||
*
|
||||
* 该宏的作用是将某个 target 源的专用测速链接填充到 Source_t 中的 speed_url 字段中
|
||||
*
|
||||
* 即使不需要该宏也是可以的,但是代价就是维护者要维护比较重复的两个字段: url 和 speed_url
|
||||
*
|
||||
* @note 该宏仅当在 recipe 中使用, 由 <category>_<target>_sources_prepare() 调用
|
||||
*/
|
||||
#define chsrc_sources_prepare_speedurl_with_postfix(target,str) sources_prepare_speedurl_with_postfix(target##_sources, target##_sources_n, str)
|
||||
static void
|
||||
sources_prepare_speedurl_with_postfix (Source_t sources[], int n, char *postfix)
|
||||
{
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
Source_t *src = &sources[i];
|
||||
|
||||
ProviderType_t type = src->provider->type;
|
||||
|
||||
if (IS_DedicatedMirrorSite==type || IS_UpstreamProvider==type)
|
||||
{
|
||||
/* 这两个不用填,因为定义这二者的时候如果给了整体测速URL,则就是ACCURATE的,我们直接会DelegateTo那里 */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (src->url)
|
||||
{
|
||||
/* 为空时才修改 或者里面是脏数据 */
|
||||
if (NULL==src->speed_measure_url || !chef_is_url (src->speed_measure_url))
|
||||
src->speed_measure_url = xy_2strjoin (src->url, postfix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 自动测速选择镜像站和源
|
||||
*/
|
||||
@@ -1124,6 +1088,38 @@ chsrc_set_provider_speed_measure_accuracy (SourceProvider_t *provider, bool accu
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 填充专用测速链接
|
||||
*/
|
||||
static void
|
||||
chsrc_set_sources_speed_measure_url_with_postfix (Target_t *target, char *postfix)
|
||||
{
|
||||
Source_t *sources = &target->sources;
|
||||
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
Source_t *src = &sources[i];
|
||||
|
||||
ProviderType_t type = src->provider->type;
|
||||
|
||||
if (IS_DedicatedMirrorSite==type)
|
||||
{
|
||||
/* 这个不用填,因为定义它的时候如果给了整体测速URL,则就是ACCURATE的,我们直接会DelegateTo那里 */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (src->url)
|
||||
{
|
||||
/* 为空时才修改 或者里面是脏数据 */
|
||||
if (NULL==src->speed_measure_url || !chef_is_url (src->speed_measure_url))
|
||||
src->speed_measure_url = xy_2strjoin (src->url, postfix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
chsrc_determine_chgtype (ChgType_t type)
|
||||
{
|
||||
|
||||
@@ -92,9 +92,7 @@ Source_t;
|
||||
/* 看到该注释的贡献者,你可以帮忙寻找专用测速链接 */
|
||||
#define NeedContribute NULL
|
||||
/* 由 _sources_prepare 填充 */
|
||||
#define FeedBySourcesPrepare NULL
|
||||
/* 由 prelude() 修改 */
|
||||
#define ChangedByPrelude NULL
|
||||
#define FeedByPrelude NULL
|
||||
|
||||
#define def_sources_n(t) const size_t t##_sources_n = xy_arylen(t##_sources)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user