mesatee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ms...@apache.org
Subject [incubator-mesatee] branch master updated: Storage dir can be set by env var (MESATEE_STORAGE_DIR) (#88)
Date Sat, 23 Nov 2019 06:58:28 GMT
This is an automated email from the ASF dual-hosted git repository.

mssun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mesatee.git


The following commit(s) were added to refs/heads/master by this push:
     new 4ab5343  Storage dir can be set by env var (MESATEE_STORAGE_DIR) (#88)
4ab5343 is described below

commit 4ab5343f4ee9f57d6e914f1068e5b9d6637afa17
Author: Mingshen Sun <bob@mssun.me>
AuthorDate: Fri Nov 22 22:58:22 2019 -0800

    Storage dir can be set by env var (MESATEE_STORAGE_DIR) (#88)
---
 docs/how_to_build.md                                    | 1 +
 mesatee_services/tdfs/sgx_trusted_lib/src/data_store.rs | 9 +++++++--
 tests/integration_test/test_data/test.toml              | 2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/docs/how_to_build.md b/docs/how_to_build.md
index 3626ba7..5285053 100644
--- a/docs/how_to_build.md
+++ b/docs/how_to_build.md
@@ -93,6 +93,7 @@ help set the variables. Below is the description for the environment variables:
 * ``MESATEE_PROJECT_ROOT``: MesaTEE project root directory
 * ``MESATEE_CFG_DIR``: directory containing the runtime config
 * ``MESATEE_BUILD_CFG_DIR``: directory containing the compile time config
+* `MESATEE_SOTRAGE_DIR`: directory for TDFS data storage, default is `/tmp`
 * ``MESATEE_AUDITORS_DIR``: directory containing auditors' public keys and endorsement to
TEE enclaves (digital signatures)
 * ``MESATEE_TEST_MODE``: whether executing in testing mode
 * ``RUST_LOG``: logging levels
diff --git a/mesatee_services/tdfs/sgx_trusted_lib/src/data_store.rs b/mesatee_services/tdfs/sgx_trusted_lib/src/data_store.rs
index 5e35848..657b901 100644
--- a/mesatee_services/tdfs/sgx_trusted_lib/src/data_store.rs
+++ b/mesatee_services/tdfs/sgx_trusted_lib/src/data_store.rs
@@ -20,7 +20,8 @@ use lazy_static::lazy_static;
 use mesatee_core::db::Memdb;
 use mesatee_core::{Error, ErrorKind, Result};
 use std::collections::HashSet;
-use std::format;
+use std::env;
+use std::path::Path;
 use std::sync::SgxMutex;
 
 #[derive(Clone)]
@@ -51,7 +52,11 @@ lazy_static! {
 
 impl FileMeta {
     pub fn get_access_path(&self) -> String {
-        format!("/tmp/{}", self.storage_path)
+        let storage_dir = env::var("MESATEE_STORAGE_DIR").unwrap_or_else(|_| "/tmp".into());
+        Path::new(&storage_dir)
+            .join(&self.storage_path)
+            .to_string_lossy()
+            .to_string()
     }
 
     pub fn check_permission(&self, user_id: &str) -> bool {
diff --git a/tests/integration_test/test_data/test.toml b/tests/integration_test/test_data/test.toml
index 6521372..5399ce1 100644
--- a/tests/integration_test/test_data/test.toml
+++ b/tests/integration_test/test_data/test.toml
@@ -63,7 +63,7 @@ payload = """
 {"type":"Get","file_id":"fake_file_record","user_id":"fake_file_owner","user_token":"token"}
 """
 expected = """
-{"type":"Get","file_info":{"user_id":"fake_file_owner","file_name":"fake_file","sha256":"aaa","file_size":100,"access_path":"/tmp/fake_file","task_id":null,"collaborator_list":[],"key_config":{"key":"QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUE=","nonce":"QUFBQUFBQUFBQUFB","ad":"QUFBQUE="}}}
+{"type":"Get","file_info":{"user_id":"fake_file_owner","file_name":"fake_file","sha256":"aaa","file_size":100,"access_path":"/*/fake_file","task_id":null,"collaborator_list":[],"key_config":{"key":"QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUE=","nonce":"QUFBQUFBQUFBQUFB","ad":"QUFBQUE="}}}
 """
 
 [[step]]


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@mesatee.apache.org
For additional commands, e-mail: commits-help@mesatee.apache.org


Mime
View raw message