[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Duplicity-talk] S3 ECONNRESET during restore results in SHA1 hash m
From: |
Aphyr |
Subject: |
Re: [Duplicity-talk] S3 ECONNRESET during restore results in SHA1 hash mismatch |
Date: |
Tue, 10 May 2016 11:22:31 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.7.0 |
On 05/04/2016 04:07 PM, address@hidden wrote:
probably should, but nobody contributed that so far ;).. ede/duply.net
To follow up: I was never able to figure out why the backend returns
successfully after ECONNRESET (alas, my understanding of python error handling
is still tentative), but I *was* able to complete my restore by patching
restore_get_enc_fileobj to retry downloads when signature verification failed.
Here's my (probably terrible) solution, in case anyone else runs into a similar
problem.
def restore_get_enc_fileobj(backend, filename, volume_info):
"""
Return plaintext fileobj from encrypted filename on backend
If volume_info is set, the hash of the file will be checked,
assuming some hash is available. Also, if globals.sign_key is
set, a fatal error will be raised if file not signed by sign_key.
"""
parseresults = file_naming.parse(filename)
for n in range(100):
tdp = dup_temp.new_tempduppath(parseresults)
backend.get(filename, tdp)
""" verify hash of the remote file """
verified, hash_pair, calculated_hash = restore_check_hash(volume_info,
tdp)
if verified:
break
""" verification failed """
log.Warn("%s\n %s\n %s\n %s\n" %
(_("Invalid data - %s hash mismatch for file:") %
hash_pair[0],
util.ufn(filename),
_("Calculated hash: %s") % calculated_hash,
_("Manifest hash: %s") % hash_pair[1]),
log.ErrorCode.mismatched_hash)
""" abandon file and retry """
tdp.delete()
time.sleep(10)
fileobj = tdp.filtered_open_with_delete("rb")
if parseresults.encrypted and globals.gpg_profile.sign_key:
restore_add_sig_check(fileobj)
return fileobj
--Kyle