"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Tools/Commandline/ReEncrypt/ReEncrypt.py" between
duplicati-2.0.5.104-2.0.5.104_canary_2020-03-25.tar.gz and duplicati-2.0.5.106-2.0.5.106_canary_2020-05-11.tar.gz

About: Duplicati is a backup client that securely stores encrypted, incremental, compressed backups on local devices, cloud storage services and remote file servers (for Windows, macOS and Linux). A remark: This officially "pre-release" seems to run stable.

ReEncrypt.py  (duplicati-2.0.5.104-2.0.5.104_canary_2020-03-25):ReEncrypt.py  (duplicati-2.0.5.106-2.0.5.106_canary_2020-05-11)
skipping to change at line 62 skipping to change at line 62
def handleIndex(options, dindex_enc): def handleIndex(options, dindex_enc):
with NamedTemporaryFile() as temp_dindex, NamedTemporaryFile() as temp_dinde x_reenc, TemporaryDirectory() as temp_path_zip: with NamedTemporaryFile() as temp_dindex, NamedTemporaryFile() as temp_dinde x_reenc, TemporaryDirectory() as temp_path_zip:
dindex_enc_fullpath = os.path.join(options['orig']['path'],dindex_enc) dindex_enc_fullpath = os.path.join(options['orig']['path'],dindex_enc)
dindex_reenc_fullpath = os.path.join(options['new']['path'],change_ext(d index_enc,options['orig']['extension'],options['new']['extension'])) dindex_reenc_fullpath = os.path.join(options['new']['path'],change_ext(d index_enc,options['orig']['extension'],options['new']['extension']))
decrypt(options['orig'],dindex_enc_fullpath,options['orig']['passwd'],te mp_dindex.name) decrypt(options['orig'],dindex_enc_fullpath,options['orig']['passwd'],te mp_dindex.name)
unzip(temp_dindex,temp_path_zip) unzip(temp_dindex,temp_path_zip)
vol_path = os.path.join(temp_path_zip,'vol') vol_path = os.path.join(temp_path_zip,'vol')
if os.path.exists(vol_path):
for dblock in os.listdir(vol_path):
data = []
with open(os.path.join(vol_path, dblock)) as data_file:
data = json.load(data_file, object_pairs_hook=OrderedDict)
expected_hash = data['volumehash'].encode('utf8')
expected_volumesize = data['volumesize']
if (options['verify_hash']):
actual_hash = computeHash(os.path.join(options['orig']['path
'],dblock))
actual_volumesize=os.stat(os.path.join(options['orig']['path
'],dblock)).st_size
print('dblock: %s expected_hash: %s calc_hash: %s exact: %s'
% (dblock,expected_hash.decode('utf8'),actual_hash.decode('utf8'),expected_hash
==actual_hash))
with NamedTemporaryFile() as temp_dblock:
dblock_enc_fullpath = os.path.join(options['orig']['path'],d
block)
dblock_reenc_fullpath = os.path.join(options['new']['path'],
change_ext(dblock,options['orig']['extension'],options['new']['extension']))
decrypt(options['orig'],dblock_enc_fullpath,options['orig'][
'passwd'],temp_dblock.name)
encrypt(options['new'],temp_dblock.name,options['new']['pass
wd'], dblock_reenc_fullpath)
new_hash = computeHash(dblock_reenc_fullpath)
data['volumehash'] = new_hash.decode('utf8')
data['volumesize'] = os.stat(os.path.join(options['new']['path']
,change_ext(dblock,options['orig']['extension'],options['new']['extension']))).s
t_size
print('dblock: %s old_hash: %s new_hash: %s' % (dblock,expected_
hash.decode('utf8'),data['volumehash']))
for dblock in os.listdir(vol_path): with open(os.path.join(vol_path,dblock),'w') as data_file:
data = [] json.dump(data, data_file)
with open(os.path.join(vol_path, dblock)) as data_file:
data = json.load(data_file, object_pairs_hook=OrderedDict)
expected_hash = data['volumehash'].encode('utf8')
expected_volumesize = data['volumesize']
if (options['verify_hash']):
actual_hash = computeHash(os.path.join(options['orig']['path'],d
block))
actual_volumesize=os.stat(os.path.join(options['orig']['path'],d
block)).st_size
print('dblock: %s expected_hash: %s calc_hash: %s exact: %s' % (
dblock,expected_hash.decode('utf8'),actual_hash.decode('utf8'),expected_hash==ac
tual_hash))
with NamedTemporaryFile() as temp_dblock:
dblock_enc_fullpath = os.path.join(options['orig']['path'],dbloc
k)
dblock_reenc_fullpath = os.path.join(options['new']['path'],chan
ge_ext(dblock,options['orig']['extension'],options['new']['extension']))
decrypt(options['orig'],dblock_enc_fullpath,options['orig']['pas
swd'],temp_dblock.name)
encrypt(options['new'],temp_dblock.name,options['new']['passwd']
, dblock_reenc_fullpath)
new_hash = computeHash(dblock_reenc_fullpath)
data['volumehash'] = new_hash.decode('utf8')
data['volumesize'] = os.stat(os.path.join(options['new']['path'],cha
nge_ext(dblock,options['orig']['extension'],options['new']['extension']))).st_si
ze
print('dblock: %s old_hash: %s new_hash: %s' % (dblock,expected_hash
.decode('utf8'),data['volumehash']))
with open(os.path.join(vol_path,dblock),'w') as data_file: os.rename(os.path.join(vol_path, dblock), os.path.join(vol_path,
json.dump(data, data_file) change_ext(dblock,options['orig']['extension'],options['new']['extension'])))
os.rename(os.path.join(vol_path, dblock), os.path.join(vol_path, cha
nge_ext(dblock,options['orig']['extension'],options['new']['extension'])))
make_zipfile(temp_dindex_reenc.name,temp_path_zip) make_zipfile(temp_dindex_reenc.name,temp_path_zip)
encrypt(options['new'],temp_dindex_reenc.name, options['new']['passwd'], dindex_reenc_fullpath) encrypt(options['new'],temp_dindex_reenc.name, options['new']['passwd'], dindex_reenc_fullpath)
def change_ext(filename, ext_old, ext_new): def change_ext(filename, ext_old, ext_new):
return filename.replace(ext_old, ext_new) return filename.replace(ext_old, ext_new)
def decrypt(options, encrypted, passw, decrypted): def decrypt(options, encrypted, passw, decrypted):
print('decrypting: %s to %s' % (encrypted, decrypted)) print('decrypting: %s to %s' % (encrypted, decrypted))
if options['encryption']=='aes': if options['encryption']=='aes':
 End of changes. 3 change blocks. 
39 lines changed or deleted 39 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)