mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-09-04 00:44:21 +00:00
Add config options: fixed_block_size and web_token_expire_time
This commit is contained in:
@@ -662,7 +662,7 @@ chunking_worker (gpointer vdata, gpointer user_data)
|
||||
if (chunk->result < 0)
|
||||
goto out;
|
||||
|
||||
idx = chunk->offset / FIXED_BLOCK_SIZE;
|
||||
idx = chunk->offset / seaf->http_server->fixed_block_size;
|
||||
memcpy (data->blk_sha1s + idx * CHECKSUM_LENGTH, chunk->checksum, CHECKSUM_LENGTH);
|
||||
|
||||
out:
|
||||
@@ -689,7 +689,7 @@ split_file_to_block (const char *repo_id,
|
||||
CDCDescriptor *chunk;
|
||||
int ret = 0;
|
||||
|
||||
n_blocks = (file_size + BLOCK_SZ - 1) / BLOCK_SZ;
|
||||
n_blocks = (file_size + seaf->http_server->fixed_block_size - 1) / seaf->http_server->fixed_block_size;
|
||||
block_sha1s = g_new0 (uint8_t, n_blocks * CHECKSUM_LENGTH);
|
||||
if (!block_sha1s) {
|
||||
seaf_warning ("Failed to allocate block_sha1s.\n");
|
||||
@@ -720,7 +720,7 @@ split_file_to_block (const char *repo_id,
|
||||
guint64 len;
|
||||
guint64 left = (guint64)file_size;
|
||||
while (left > 0) {
|
||||
len = ((left >= FIXED_BLOCK_SIZE) ? FIXED_BLOCK_SIZE : left);
|
||||
len = ((left >= seaf->http_server->fixed_block_size) ? seaf->http_server->fixed_block_size : left);
|
||||
|
||||
chunk = g_new0 (CDCDescriptor, 1);
|
||||
chunk->offset = offset;
|
||||
|
@@ -111,6 +111,8 @@ load_http_config (HttpServerStruct *htp_server, SeafileSession *session)
|
||||
GError *error = NULL;
|
||||
char *host = NULL;
|
||||
int port = 0;
|
||||
int web_token_expire_time;
|
||||
int fixed_block_size_mb;
|
||||
int max_upload_size_mb;
|
||||
int max_download_dir_size_mb;
|
||||
char *encoding;
|
||||
@@ -144,6 +146,32 @@ load_http_config (HttpServerStruct *htp_server, SeafileSession *session)
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
fixed_block_size_mb = fileserver_config_get_integer (session->config,
|
||||
"fixed_block_size",
|
||||
&error);
|
||||
if (error){
|
||||
htp_server->fixed_block_size = BLOCK_SZ;
|
||||
g_clear_error(&error);
|
||||
} else {
|
||||
if (fixed_block_size_mb <= 0)
|
||||
htp_server->fixed_block_size = BLOCK_SZ;
|
||||
else
|
||||
htp_server->fixed_block_size = fixed_block_size_mb * ((gint64)1 << 20);
|
||||
}
|
||||
|
||||
web_token_expire_time = fileserver_config_get_integer (session->config,
|
||||
"web_token_expire_time",
|
||||
&error);
|
||||
if (error){
|
||||
htp_server->web_token_expire_time = 3600; /* default 3600s */
|
||||
g_clear_error(&error);
|
||||
} else {
|
||||
if (web_token_expire_time <= 0)
|
||||
htp_server->web_token_expire_time = 3600; /* default 3600s */
|
||||
else
|
||||
htp_server->web_token_expire_time = web_token_expire_time;
|
||||
}
|
||||
|
||||
max_upload_size_mb = fileserver_config_get_integer (session->config,
|
||||
"max_upload_size",
|
||||
&error);
|
||||
|
@@ -16,8 +16,10 @@ struct _HttpServerStruct {
|
||||
int bind_port;
|
||||
char *http_temp_dir; /* temp dir for file upload */
|
||||
char *windows_encoding;
|
||||
gint64 fixed_block_size;
|
||||
gint64 max_upload_size;
|
||||
gint64 max_download_dir_size;
|
||||
int web_token_expire_time;
|
||||
int max_indexing_threads;
|
||||
};
|
||||
|
||||
|
@@ -156,7 +156,7 @@ seaf_web_at_manager_get_access_token (SeafWebAccessTokenManager *mgr,
|
||||
pthread_mutex_lock (&mgr->priv->lock);
|
||||
|
||||
t = gen_new_token (mgr->priv->access_token_hash);
|
||||
expire = now + TOKEN_EXPIRE_TIME;
|
||||
expire = now + seaf->http_server->web_token_expire_time;
|
||||
|
||||
info = g_new0 (AccessInfo, 1);
|
||||
info->repo_id = g_strdup (repo_id);
|
||||
|
Reference in New Issue
Block a user