From f319bd834dda521e18a05e15b8318fffeb097a5c Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Wed, 14 Jan 2015 21:50:47 -0500 Subject: combox/crypto.py: relative_path function is used to get the file/directory's basename. --- combox/crypto.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/combox/crypto.py b/combox/crypto.py index 1cf0bc1..a6f2afe 100644 --- a/combox/crypto.py +++ b/combox/crypto.py @@ -24,7 +24,8 @@ import os from combox.config import get_nodedirs from combox.file import (read_file, write_file, read_shards, write_shards, - split_data, glue_data) + split_data, glue_data, + relative_path) from Crypto.Cipher import AES from os import path @@ -98,10 +99,12 @@ def split_and_encrypt(fpath, config): config: The dictonary containing the combox configuration information. """ + rel_path = relative_path(fpath, config) + # no. of shards = no. of nodes. SHARDS = len(config['nodes_info'].keys()) - f = path.abspath(fpath) + f = path.join(config['combox_dir'], rel_path) f_content = read_file(f) f_shards = split_data(f_content, SHARDS) @@ -110,7 +113,7 @@ def split_and_encrypt(fpath, config): # write ciphered shards to disk - f_basename = path.basename(f) + f_basename = rel_path # gets the list of node' directories. nodes = get_nodedirs(config) @@ -127,8 +130,10 @@ def decrypt_and_glue(fpath, config): """ + rel_path = relative_path(fpath, config) + f = path.abspath(fpath) - f_basename = path.basename(f) + f_basename = rel_path # gets the list of node' directories. nodes = get_nodedirs(config) -- cgit v1.2.3