Page MenuHomePhabricator

D9017.id30537.diff
No OneTemporary

D9017.id30537.diff

diff --git a/services/backup/Cargo.lock b/services/backup/Cargo.lock
--- a/services/backup/Cargo.lock
+++ b/services/backup/Cargo.lock
@@ -759,7 +759,6 @@
"comm-services-lib",
"derive_more",
"once_cell",
- "rand",
"reqwest",
"serde",
"serde_json",
diff --git a/services/backup/Cargo.toml b/services/backup/Cargo.toml
--- a/services/backup/Cargo.toml
+++ b/services/backup/Cargo.toml
@@ -19,7 +19,6 @@
"blob-client",
] }
once_cell = "1.17"
-rand = "0.8.5"
tokio = { version = "1.24", features = ["rt-multi-thread", "macros"] }
tokio-stream = "0.1"
tracing = "0.1"
diff --git a/services/backup/src/main.rs b/services/backup/src/main.rs
--- a/services/backup/src/main.rs
+++ b/services/backup/src/main.rs
@@ -8,7 +8,6 @@
pub mod database;
pub mod error;
pub mod http;
-pub mod utils;
// re-export this to be available as crate::CONFIG
pub use config::CONFIG;
diff --git a/services/backup/src/utils.rs b/services/backup/src/utils.rs
deleted file mode 100644
--- a/services/backup/src/utils.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-use rand::{distributions::DistString, CryptoRng, Rng};
-use uuid::Uuid;
-
-use crate::constants::ID_SEPARATOR;
-
-/// Generates a blob `holder` string used to store backup/log data
-/// in Blob service
-pub fn generate_blob_holder(
- blob_hash: &str,
- backup_id: &str,
- resource_id: Option<&str>,
-) -> String {
- format!(
- "{backup_id}{sep}{resource_id}{sep}{blob_hash}{sep}{uuid}",
- backup_id = backup_id,
- resource_id = resource_id.unwrap_or_default(),
- blob_hash = blob_hash,
- sep = ID_SEPARATOR,
- uuid = Uuid::new_v4()
- )
-}
-
-pub fn generate_random_string(
- length: usize,
- rng: &mut (impl Rng + CryptoRng),
-) -> String {
- rand::distributions::Alphanumeric.sample_string(rng, length)
-}
diff --git a/services/comm-services-lib/src/tools.rs b/services/comm-services-lib/src/tools.rs
--- a/services/comm-services-lib/src/tools.rs
+++ b/services/comm-services-lib/src/tools.rs
@@ -1,3 +1,5 @@
+use rand::{distributions::DistString, CryptoRng, Rng};
+
// colon is valid because it is used as a separator
// in some backup service identifiers
const VALID_IDENTIFIER_CHARS: &'static [char] = &['_', '-', '=', ':'];
@@ -72,6 +74,13 @@
}
}
+pub fn generate_random_string(
+ length: usize,
+ rng: &mut (impl Rng + CryptoRng),
+) -> String {
+ rand::distributions::Alphanumeric.sample_string(rng, length)
+}
+
#[cfg(test)]
mod valid_identifier_tests {
use super::*;

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 7:06 PM (20 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2580468
Default Alt Text
D9017.id30537.diff (2 KB)

Event Timeline