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

Optimize the configure options. #269

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ly1217
Copy link
Contributor

@ly1217 ly1217 commented Oct 3, 2019

No description provided.

@ly1217 ly1217 force-pushed the optimize_configure_options branch 11 times, most recently from daa129f to f6c97e9 Compare October 4, 2019 10:56
if (strcmp (group, "zip") == 0 &&
strcmp (key, "windows_encoding") == 0) {
setlocale (LC_ALL, "en_US.UTF-8");
}
Copy link
Member

Choose a reason for hiding this comment

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

不应该在这里针对一个选项加一些“副作用”逻辑,这些逻辑应该在具体的业务模块里面做。

}

cache_key = g_strdup_printf ("%s,%s", group, key);
cache_value = g_strdup_printf ("%s,%s", value, property);
Copy link
Member

Choose a reason for hiding this comment

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

这个哈希表的 value 应该定义一个结构体,key 用 group/key 这种字符串更好。

return NULL;
}
mgr->config_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
load_config_cache (mgr);
Copy link
Member

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;
};
Copy link
Member

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"
Copy link
Member

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
Copy link
Member

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;
Copy link
Member

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 这样的配置变量,都应该从结构体中删除,这样才能保证没有漏改的代码。

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

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

这里为什么要改呢?

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

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

seaf 这个变量不用传了,因为是全局的。

@ly1217 ly1217 force-pushed the optimize_configure_options branch 6 times, most recently from d60f281 to a2ddf9c Compare October 12, 2019 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants