Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bit of a refactor #1

Merged
merged 10 commits into from
Oct 24, 2022
Prev Previous commit
Next Next commit
Rename i to file_data
  • Loading branch information
Speykious committed Oct 24, 2022
commit b094c13ee3a7675c0702774870819c2653e5a17a
10 changes: 5 additions & 5 deletions src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ pub fn read_combined_file(file_path: String) -> Vec<FileData> {
pub async fn recreate_files(combined_data: Vec<FileData>, keys: Option<&Keys>) {
let mut task_list = Vec::new();

for i in combined_data {
let filepath = i.path;
for file_data in combined_data {
let filepath = file_data.path;

std::fs::create_dir_all(filepath.parent().unwrap())
.expect("Failed to create all the required directories/subdirectories");
Expand All @@ -147,10 +147,10 @@ pub async fn recreate_files(combined_data: Vec<FileData>, keys: Option<&Keys>) {
match keys {
Some(keys) => {
// Check the signature
keys.verify(&i.data, i.signature);
keys.verify(&file_data.data, &file_data.signature);

// Decrypt the file
let decrypted_data = decrypt(i.data, keys.keypair.secret.as_bytes(), &keys.nonce)
let decrypted_data = decrypt(file_data.data, keys.keypair.secret.as_bytes(), &keys.nonce)
.expect("Failed to decrypt the data");

// Decompress the data
Expand All @@ -172,7 +172,7 @@ pub async fn recreate_files(combined_data: Vec<FileData>, keys: Option<&Keys>) {
None => {
// Decompress the data
let decompressed_data =
decompress(&i.data, None).expect("Failed to decompress the data.");
decompress(&file_data.data, None).expect("Failed to decompress the data.");

let write_task = task::spawn(async move {
file_write
Expand Down