Skip to content

Commit a500809

Browse files
committed
Fix warnings
Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
1 parent a9514d3 commit a500809

5 files changed

Lines changed: 16 additions & 12 deletions

File tree

src/azure.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ mod tests {
106106
}
107107
}
108108

109+
#[allow(dead_code)]
109110
fn calculate_checksum(filename: &String, data: &[u8]) {
110111
let hash = sha2_512::default().update(data).finalize();
111112
let digest = hash.digest();
@@ -217,6 +218,7 @@ async fn write_file_to_blob_streaming(
217218

218219
/// Write file to Azure blob storage (legacy version using Vec<u8>)
219220
/// TBD: Rework, do not keep whole file as Vec<u8> in memory!!!
221+
#[allow(dead_code)]
220222
async fn write_file_to_blob(
221223
filename: String,
222224
data: Vec<u8>,
@@ -378,7 +380,6 @@ async fn get_file_from_blob(filename: String) -> ReceivedFile {
378380
let blob_client = ClientBuilder::new(storage_account, storage_credential)
379381
.blob_client(storage_container, storage_blob);
380382
let blob_url_res = blob_client.url();
381-
let mut blob_url = "".to_string();
382383
let mut received_file = ReceivedFile {
383384
original_filename: "".to_string(),
384385
cached_filename: "".to_string(),
@@ -387,16 +388,13 @@ async fn get_file_from_blob(filename: String) -> ReceivedFile {
387388
};
388389
received_file.original_filename = filename.clone();
389390

390-
match blob_url_res {
391-
Ok(url) => {
392-
//println!("Blob URL: {}", url);
393-
blob_url = url.to_string();
394-
}
391+
let mut blob_url = match blob_url_res {
392+
Ok(url) => url.to_string(),
395393
Err(e) => {
396394
eprintln!("Error getting blob URL: {:?}", e);
397395
return received_file;
398396
}
399-
}
397+
};
400398
// append SAS token to blob URL
401399
blob_url.push_str(storage_sastoken);
402400
// we generate a hash of the filename to use as cache filename
@@ -527,6 +525,7 @@ async fn get_file_from_blob(filename: String) -> ReceivedFile {
527525

528526
// Implement set tags for Azure blob storage
529527
// tags are in format "key=value"
528+
#[allow(dead_code)]
530529
async fn azure_set_filename_tags(
531530
filename: String,
532531
user_tags: Vec<(String, String)>,
@@ -571,7 +570,8 @@ async fn azure_set_filename_tags(
571570
}
572571
}
573572

574-
async fn azure_list_files(directory: String) -> Vec<String> {
573+
#[allow(dead_code)]
574+
async fn azure_list_files(_directory: String) -> Vec<String> {
575575
let azure_cfg = Arc::new(get_azure_credentials("azure"));
576576
let storage_account = azure_cfg.account.as_str();
577577
let storage_key = azure_cfg.key.clone();

src/local.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ fn get_metadata_file_path(filename: &str) -> PathBuf {
100100
}
101101

102102
/// Calculate SHA-512 checksum of file data
103+
#[allow(dead_code)]
103104
fn calculate_checksum(filename: &str, data: &[u8]) {
104105
let hash = sha2_512::default().update(data).finalize();
105106
let digest = hash.digest();
@@ -157,6 +158,7 @@ async fn write_file_to_local_streaming(
157158
}
158159

159160
/// Write file to local storage (legacy version using Vec<u8>)
161+
#[allow(dead_code)]
160162
fn write_file_to_local(
161163
filename: String,
162164
data: Vec<u8>,
@@ -298,6 +300,7 @@ fn list_files_in_local(directory: String) -> Vec<String> {
298300
}
299301

300302
/// Set tags for local storage (stored in metadata)
303+
#[allow(dead_code)]
301304
fn set_tags_for_local_file(
302305
filename: String,
303306
user_tags: Vec<(String, String)>,

src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ impl<'a> tokio::io::AsyncRead for FieldStream<'a> {
190190
}
191191
}
192192

193+
#[allow(dead_code)]
193194
#[async_trait]
194195
trait Driver: Send + Sync {
195196
async fn write_file(
@@ -1149,6 +1150,7 @@ async fn driver_get_file(filepath: String) -> ReceivedFile {
11491150
driver.get_file(filepath).await
11501151
}
11511152

1153+
#[allow(dead_code)]
11521154
async fn write_file_driver(
11531155
filename: String,
11541156
data: Vec<u8>,

src/storcaching.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{debug_log, get_config_content};
1+
use crate::get_config_content;
22
use serde::Deserialize;
33
use std::cmp::Ordering;
44
use std::collections::{BinaryHeap, HashSet};
@@ -325,15 +325,14 @@ pub async fn cache_loop(cache_dir: &str) {
325325
let cleanup_chunk_size = config.cleanup_chunk_size.max(1);
326326
let mut deleted_entries_counter: u64 = 0;
327327
let mut reclaimed_bytes_counter: u64 = 0;
328-
let mut cached_file_count: usize = 0;
329328
let mut next_log = Instant::now();
330329

331330
loop {
332331
let (limit_outcome, file_count) =
333332
enforce_cache_file_limit(cache_dir, cleanup_chunk_size).await;
334333
deleted_entries_counter += limit_outcome.deleted_entries;
335334
reclaimed_bytes_counter += limit_outcome.reclaimed_bytes;
336-
cached_file_count = file_count;
335+
let mut cached_file_count = file_count;
337336

338337
let mut free_space = freediskspace_percent(cache_dir).await;
339338
if free_space < DISK_SPACE_LOW_PERCENT {

src/storjwt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{debug_log, get_config_content};
1+
use crate::get_config_content;
22
use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, Validation};
33
use serde::{Deserialize, Serialize};
44
use std::collections::BTreeMap;

0 commit comments

Comments
 (0)