mirror of
https://github.com/haiwen/seafile.git
synced 2025-01-08 11:57:44 +08:00
add block_size configuration
This commit is contained in:
parent
d646a600b2
commit
ec3ea3cf35
@ -684,9 +684,15 @@ seaf_fs_manager_index_blocks (SeafFSManager *mgr,
|
||||
} else {
|
||||
memset (&cdc, 0, sizeof(cdc));
|
||||
|
||||
cdc.block_sz = CDC_AVERAGE_BLOCK_SIZE;
|
||||
cdc.block_min_sz = CDC_MIN_BLOCK_SIZE;
|
||||
cdc.block_max_sz = CDC_MAX_BLOCK_SIZE;
|
||||
if (seaf->cdc_average_block_size == 0) {
|
||||
cdc.block_sz = CDC_AVERAGE_BLOCK_SIZE;
|
||||
cdc.block_min_sz = CDC_MIN_BLOCK_SIZE;
|
||||
cdc.block_max_sz = CDC_MAX_BLOCK_SIZE;
|
||||
} else {
|
||||
cdc.block_sz = seaf->cdc_average_block_size;
|
||||
cdc.block_min_sz = seaf->cdc_average_block_size >> 1;
|
||||
cdc.block_max_sz = seaf->cdc_average_block_size << 1;
|
||||
}
|
||||
cdc.write_block = seafile_write_chunk;
|
||||
memcpy (cdc.repo_id, repo_id, 36);
|
||||
cdc.version = version;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define KEY_DB_NAME "db_name"
|
||||
#define KEY_UPLOAD_LIMIT "upload_limit"
|
||||
#define KEY_DOWNLOAD_LIMIT "download_limit"
|
||||
#define KEY_CDC_AVERAGE_BLOCK_SIZE "block_size"
|
||||
#define KEY_ALLOW_INVALID_WORKTREE "allow_invalid_worktree"
|
||||
#define KEY_ALLOW_REPO_NOT_FOUND_ON_SERVER "allow_repo_not_found_on_server"
|
||||
#define KEY_SYNC_EXTRA_TEMP_FILE "sync_extra_temp_file"
|
||||
|
@ -413,6 +413,12 @@ seafile_session_prepare (SeafileSession *session)
|
||||
seafile_session_config_get_string(session, KEY_PROXY_PASSWORD);
|
||||
}
|
||||
|
||||
int block_size = seafile_session_config_get_int(session, KEY_CDC_AVERAGE_BLOCK_SIZE, NULL);
|
||||
if (block_size > 0)
|
||||
session->cdc_average_block_size = block_size;
|
||||
else
|
||||
session->cdc_average_block_size = 0;
|
||||
|
||||
/* Start mq manager earlier, so that we can send notifications
|
||||
* when start repo manager. */
|
||||
seaf_mq_manager_init (session->mq_mgr);
|
||||
|
@ -53,6 +53,7 @@ struct _SeafileSession {
|
||||
char *deleted_store;
|
||||
char *rpc_socket_path;
|
||||
|
||||
uint32_t cdc_average_block_size;
|
||||
SeafBlockManager *block_mgr;
|
||||
SeafFSManager *fs_mgr;
|
||||
SeafCommitManager *commit_mgr;
|
||||
|
@ -319,12 +319,22 @@ compare_file_content (const char *path, SeafStat *st, const unsigned char *ce_sh
|
||||
memset (sha1, 0, 20);
|
||||
return hashcmp (sha1, ce_sha1);
|
||||
} else {
|
||||
if (compute_file_id_with_cdc (path, st, crypt, repo_version,
|
||||
CDC_AVERAGE_BLOCK_SIZE,
|
||||
CDC_MIN_BLOCK_SIZE,
|
||||
CDC_MAX_BLOCK_SIZE,
|
||||
sha1) < 0) {
|
||||
return -1;
|
||||
if (seaf->cdc_average_block_size == 0) {
|
||||
if (compute_file_id_with_cdc (path, st, crypt, repo_version,
|
||||
CDC_AVERAGE_BLOCK_SIZE,
|
||||
CDC_MIN_BLOCK_SIZE,
|
||||
CDC_MAX_BLOCK_SIZE,
|
||||
sha1) < 0) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (compute_file_id_with_cdc (path, st, crypt, repo_version,
|
||||
seaf->cdc_average_block_size,
|
||||
seaf->cdc_average_block_size >> 1,
|
||||
seaf->cdc_average_block_size << 1,
|
||||
sha1) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (hashcmp (sha1, ce_sha1) == 0)
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user