-
Notifications
You must be signed in to change notification settings - Fork 220
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
Optimize the configure options. #269
base: master
Are you sure you want to change the base?
Conversation
daa129f
to
f6c97e9
Compare
common/config-mgr.c
Outdated
if (strcmp (group, "zip") == 0 && | ||
strcmp (key, "windows_encoding") == 0) { | ||
setlocale (LC_ALL, "en_US.UTF-8"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不应该在这里针对一个选项加一些“副作用”逻辑,这些逻辑应该在具体的业务模块里面做。
common/config-mgr.c
Outdated
} | ||
|
||
cache_key = g_strdup_printf ("%s,%s", group, key); | ||
cache_value = g_strdup_printf ("%s,%s", value, property); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个哈希表的 value 应该定义一个结构体,key 用 group/key 这种字符串更好。
common/config-mgr.c
Outdated
return NULL; | ||
} | ||
mgr->config_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); | ||
load_config_cache (mgr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 load_config_cache 应该放在 seaf_cfg_manager_init 函数里面调用。而且不要把对 seaf_cfg_manager_init 函数的调用放在 seaf_cfg_manager_new 函数里面,两个是分开的。
@@ -7,6 +7,7 @@ typedef struct _SeafCfgManager SeafCfgManager; | |||
struct _SeafCfgManager { | |||
GKeyFile *config; | |||
SeafDB *db; | |||
GHashTable *config_cache; | |||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个结构体应该只包含一个 SeafCfgMgrPriv 的指针,然后 Priv 这个机构在 .c 文件中定义。一般不要把内部的数据机构暴露在头文件中。
common/fs-mgr.c
Outdated
@@ -31,8 +31,11 @@ | |||
#endif /* SEAFILE_SERVER */ | |||
|
|||
#include "db.h" | |||
#include "../server/fileserver-config.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个头文件应该删除掉了。
common/fs-mgr.c
Outdated
|
||
#define SEAF_TMP_EXT "~" | ||
#define DEFAULT_FIXED_BLOCK_SIZE ((gint64)1 << 23) /* 8MB */ | ||
#define DEFAULT_MAX_INDEXING_THREADS 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
默认值的处理应该在 config manager 里面做好。
@@ -646,7 +656,7 @@ chunking_worker (gpointer vdata, gpointer user_data) | |||
if (chunk->result < 0) | |||
goto out; | |||
|
|||
idx = chunk->offset / seaf->http_server->fixed_block_size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
所有类似 seaf->http_server->fixed_block_size 这样的配置变量,都应该从结构体中删除,这样才能保证没有漏改的代码。
server/quota-mgr.c
Outdated
@@ -28,7 +28,7 @@ get_default_quota (SeafCfgManager *mgr) | |||
gint64 quota; | |||
|
|||
quota_str = seaf_cfg_manager_get_config_string (mgr, "quota", "default"); | |||
if (!quota_str) | |||
if (strcmp (quota_str, "-2") == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里为什么要改呢?
server/repo-mgr.c
Outdated
@@ -293,18 +293,11 @@ scan_trash (void *data) | |||
} | |||
|
|||
static void | |||
init_scan_trash_timer (SeafRepoManagerPriv *priv, GKeyFile *config) | |||
init_scan_trash_timer (SeafRepoManagerPriv *priv, SeafileSession *seaf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seaf 这个变量不用传了,因为是全局的。
d60f281
to
a2ddf9c
Compare
a2ddf9c
to
49ee3a0
Compare
No description provided.