From ca23bd6cee5f60760d608e5a9687756180bd312f Mon Sep 17 00:00:00 2001 From: HouXiaoxuan Date: Fri, 5 Jul 2024 00:19:51 +0800 Subject: [PATCH 1/4] add `rpath` in `build.rs` because cargo didn't pass crate's args to current project. According to `https://github.com/rust-lang/cargo/issues/5077` Signed-off-by: HouXiaoxuan --- mega/src/build.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mega/src/build.rs b/mega/src/build.rs index 77fc2d867..27ec449e9 100644 --- a/mega/src/build.rs +++ b/mega/src/build.rs @@ -4,5 +4,9 @@ //! fn main() -> shadow_rs::SdResult<()> { + #[cfg(target_os = "linux")] + println!("cargo:rustc-link-arg=-Wl,-rpath,$ORIGIN"); + #[cfg(target_os = "macos")] + println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path"); shadow_rs::new() } \ No newline at end of file From f934750577e3c0770b93c0407f9f16490fcf6b8a Mon Sep 17 00:00:00 2001 From: HouXiaoxuan Date: Fri, 5 Jul 2024 00:39:31 +0800 Subject: [PATCH 2/4] split lfs: doc config.toml Signed-off-by: HouXiaoxuan --- docs/development.md | 15 +++++++++ mega/config.toml | 8 +++-- mega/config.toml.example | 69 ---------------------------------------- 3 files changed, 21 insertions(+), 71 deletions(-) delete mode 100644 mega/config.toml.example diff --git a/docs/development.md b/docs/development.md index 7cd1d0074..c2a2d5d27 100644 --- a/docs/development.md +++ b/docs/development.md @@ -310,7 +310,14 @@ pack_decode_cache_path = "/tmp/.mega/cache" clean_cache_after_decode = true + + [lfs] + ## IMPORTANT: The 'enable_split' feature can only be enabled for new databases. Existing databases do not support this feature. + # Enable or disable splitting large files into smaller chunks + enable_split = false # Default is disabled. Set to true to enable file splitting. + # Size of each file chunk when splitting is enabled, in bytes. Ignored if splitting is disabled. + split_size = 20971520 # Default size is 20MB (20971520 bytes) ``` @@ -430,6 +437,14 @@ Config `confg.toml` file for the Mega project. pack_decode_cache_path = "/tmp/.mega/cache" clean_cache_after_decode = true + + [lfs] + ## IMPORTANT: The 'enable_split' feature can only be enabled for new databases. Existing databases do not support this feature. + # Enable or disable splitting large files into smaller chunks + + enable_split = false # Default is disabled. Set to true to enable file splitting. + # Size of each file chunk when splitting is enabled, in bytes. Ignored if splitting is disabled. + split_size = 20971520 # Default size is 20MB (20971520 bytes) ``` ## Comment Guideline diff --git a/mega/config.toml b/mega/config.toml index cd18828bb..bbfae4e85 100644 --- a/mega/config.toml +++ b/mega/config.toml @@ -75,5 +75,9 @@ hub = "http://127.0.0.1:8888" agent = "http://127.0.0.1:7777" [lfs] -enable_split = true -split_size = 20971520 # 20MB \ No newline at end of file +## IMPORTANT: The 'enable_split' feature can only be enabled for new databases. Existing databases do not support this feature. +# Enable or disable splitting large files into smaller chunks +enable_split = true # Default is disabled. Set to true to enable file splitting. + +# Size of each file chunk when splitting is enabled, in bytes. Ignored if splitting is disabled. +split_size = 20971520 # Default size is 20MB (20971520 bytes) \ No newline at end of file diff --git a/mega/config.toml.example b/mega/config.toml.example deleted file mode 100644 index 8406dc7b4..000000000 --- a/mega/config.toml.example +++ /dev/null @@ -1,69 +0,0 @@ -# Filling the following environment variables with values you set -## Logging Configuration -[log] -# The path which log file is saved -log_path = "/tmp/.mega/logs" - -# log level -level = "debug" - -# print std log in console, disable it on production for performance -print_std = true - - -[database] -# database connection url -db_url = "postgres://postgres:postgres@localhost:5432/mega" - -# db max connection, setting it to twice the number of CPU cores would be appropriate. -max_connection = 32 - -# db min connection, setting it to the number of CPU cores would be appropriate. -min_connection = 16 - -# Whether to disabling SQLx Log -sqlx_logging = false - - -[ssh] -ssh_key_path = "/tmp/.mega/ssh" - -[storage] -# raw object stroage type, can be `local` or `remote` -raw_obj_storage_type = "LOCAL" - -## If the object file size exceeds the threshold value, it will be handled by file storage instead of the database, Unit is KB -big_obj_threshold = 1024 - -# set the local path of the project storage -raw_obj_local_path = "/tmp/.mega/objects" - -lfs_obj_local_path = "/tmp/.mega/lfs" - -obs_access_key = "" -obs_secret_key = "" - -# cloud storage region -obs_region = "cn-east-3" - -# Override the endpoint URL used for remote storage services -obs_endpoint = "https://obs.cn-east-3.myhuaweicloud.com" - - -[monorepo] -## Only import directory support multi-branch commit and tag, repo under regular directory only support main branch only -## Mega treats files under this directory as import repo and other directories as monorepo -import_dir = "/third-part" - - -[pack] -# The maximum memory used by decode, Unit is GB -pack_decode_mem_size = 4 - -# The location where the object stored when the memory used by decode exceeds the limit -pack_decode_cache_path = "/tmp/.mega/cache" - -clean_cache_after_decode = true - -# The maximum meesage size in channel buffer while decode -channel_message_size = 1_000_000 \ No newline at end of file From c99aaf3bbd7f833c12d1eeae78a1c53aca6b47e3 Mon Sep 17 00:00:00 2001 From: HouXiaoxuan Date: Fri, 5 Jul 2024 00:41:06 +0800 Subject: [PATCH 3/4] fix doc error: 1. `init -d` not support now 2. make the sql url consistent with the database configuratio Signed-off-by: HouXiaoxuan --- docs/development.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/development.md b/docs/development.md index c2a2d5d27..8438de189 100644 --- a/docs/development.md +++ b/docs/development.md @@ -147,7 +147,7 @@ ```bash $ cd mega - $ cargo run init -d postgres + $ cargo run init ``` 7. Start the Mega server for testing. @@ -260,7 +260,7 @@ [database] # database connection url - db_url = "postgres://postgres:postgres@localhost:5432/mega" + db_url = "postgres://mega:mega@localhost:5432/mega" # db max connection, setting it to twice the number of CPU cores would be appropriate. max_connection = 32 @@ -325,7 +325,7 @@ ```bash $ cd mega - $ cargo run init -d postgres + $ cargo run init ``` 7. Start Mega server. @@ -389,7 +389,7 @@ Config `confg.toml` file for the Mega project. [database] # database connection url - db_url = "postgres://postgres:postgres@localhost:5432/mega" + db_url = "postgres://mega:mega@localhost:5432/mega" # db max connection, setting it to twice the number of CPU cores would be appropriate. max_connection = 2 From 3bf91e9eb45ec660ab284002b41c92a736deee63 Mon Sep 17 00:00:00 2001 From: HouXiaoxuan Date: Fri, 5 Jul 2024 02:34:59 +0800 Subject: [PATCH 4/4] fix: db_url in `config.toml` Signed-off-by: HouXiaoxuan --- mega/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mega/config.toml b/mega/config.toml index bbfae4e85..007acc16a 100644 --- a/mega/config.toml +++ b/mega/config.toml @@ -13,7 +13,7 @@ print_std = true [database] # database connection url -db_url = "postgres://postgres:postgres@localhost:5432/mega" +db_url = "postgres://mega:mega@localhost:5432/mega" # db max connection, setting it to twice the number of CPU cores would be appropriate. max_connection = 32