gpg: fatal: zlib inflate problem: incorrect data check (lp:#713832)

[Original report](https://bugs.launchpad.net/bugs/713832) created by **William Deninger (wdeninger)**
```
duplicity 0.6.11
Python 2.6.5
Linux SOUTH 2.6.32-27-generic #49-Ubuntu SMP Thu Dec 2 00:51:09 UTC 2010
x86_64 GNU/Linux

This has been an issue for some time (pre 0.6.8b through 0.6.11).

I create the incident by performing a full backup of a data repository path
to a mounted drive on the same system. The failure is produced when
attempting to verify, restore or file restore the specific file which
fails.

Repository backup call:
nohup duplicity --encrypt-key "8ABB1A41" --sign-key "8ABB1A41" --verbosity
9 "/media/MadDog/Archive/"
"file:///media/Poodle/backup/media/MadDog/Archive/" >> localbackup.log &

No errors or warnings are issued during the backup phase:

AsyncScheduler: running task synchronously (asynchronicity disabled)
Writing /media/Poodle/backup/./media/Poodle/Archive.dup/Photo
Archive/duplicity-full.20100902T170354Z.vol1147.difftar.gpg
Deleting /tmp/duplicity-X5gfOu-tempdir/mktemp-CVCWXz-1148
Forgetting temporary file /tmp/duplicity-X5gfOu-tempdir/mktemp-CVCWXz-1148
AsyncScheduler: task completed successfully
Processed volume 1147
Registering (mktemp) temporary file /tmp/duplicity-X5gfOu-tempdir/mktemp-
RGVAhj-1149
AsyncScheduler: running task synchronously (asynchronicity disabled)
Writing /media/Poodle/backup/./media/Poodle/Archive.dup/Photo
Archive/duplicity-full.20100902T170354Z.vol1148.difftar.gpg
Deleting /tmp/duplicity-X5gfOu-tempdir/mktemp-RGVAhj-1149
Forgetting temporary file /tmp/duplicity-X5gfOu-tempdir/mktemp-RGVAhj-1149
AsyncScheduler: task completed successfully
Processed volume 1148
Registering (mktemp) temporary file /tmp/duplicity-X5gfOu-tempdir/mktemp-
Vk9ex8-1150
AsyncScheduler: running task synchronously (asynchronicity disabled)
Writing /media/Poodle/backup/./media/Poodle/Archive.dup/Photo
Archive/duplicity-full.20100902T170354Z.vol1149.difftar.gpg
Deleting /tmp/duplicity-X5gfOu-tempdir/mktemp-Vk9ex8-1150
Forgetting temporary file /tmp/duplicity-X5gfOu-tempdir/mktemp-Vk9ex8-1150
AsyncScheduler: task completed successfully
Processed volume 1149
.
.
.
File duplicity-full.20110205T061747Z.vol3671.difftar.gpg is part of known
set
Found backup chain [Fri Feb  4 22:17:47 2011]-[Fri Feb  4 22:17:47 2011]
--------------[ Backup Statistics ]--------------
StartTime 1296886667.37 (Fri Feb  4 22:17:47 2011)
EndTime 1296901383.13 (Sat Feb  5 02:23:03 2011)
ElapsedTime 14715.76 (4 hours 5 minutes 15.76 seconds)
SourceFiles 50598
SourceFileSize 129262183781 (120 GB)
NewFiles 50598
NewFileSize 129262183781 (120 GB)
DeletedFiles 0
ChangedFiles 0
ChangedFileSize 0 (0 bytes)
ChangedDeltaSize 0 (0 bytes)
DeltaEntries 50598
RawDeltaSize 129247782245 (120 GB)
TotalDestinationSizeChange 125396358454 (117 GB)
Errors 0
-------------------------------------------------

Removing still remembered temporary file /tmp/duplicity-
ll_k8Z-tempdir/mkstemp-fl_3D4-1

During verify, restore and file restore, the following occurs which
terminates the restore process:

nohup duplicity restore --encrypt-key 8ABB1A41 --sign-key 8ABB1A41
--ignore-errors --verbosity 9
"file:///media/Poodle/backup/media/MadDog/Archive/"
"/media/Poodle/restore/" > localrestore.log &

OR

duplicity --encrypt-key 8ABB1A41 --sign-key 8ABB1A41 --verbosity debug
--file-to-restore "Photo Archive/1995/19950817 Fort Lauderdale 08.jpg"
"file:///media/Poodle/backup/media/MadDog/Archive/"
"/media/Poodle/restore2.jpg/" > duplicity-failure.log

where the file "Archive/1995/19950817 Fort Lauderdale 08.jpg" is the
failing restore.

Running in 'ignore errors' mode due to --ignore-errors; please re-consider
if this was not intended
Using archive dir: /root/.cache/duplicity/0543e0fc57cd727701c014cdcfc1718f
Using backup name: 0543e0fc57cd727701c014cdcfc1718f
Import of duplicity.backends.imapbackend Succeeded
Import of duplicity.backends.webdavbackend Succeeded
Import of duplicity.backends.sshbackend Succeeded
Import of duplicity.backends.rsyncbackend Succeeded
Import of duplicity.backends.tahoebackend Succeeded
Import of duplicity.backends.localbackend Succeeded
Import of duplicity.backends.giobackend Succeeded
Import of duplicity.backends.hsibackend Succeeded
Import of duplicity.backends.botobackend Succeeded
Import of duplicity.backends.cloudfilesbackend Succeeded
Import of duplicity.backends.ftpbackend Succeeded
Main action: restore
================================================================================
duplicity 0.6.11 (November 20, 2010)
Args: /usr/local/bin/duplicity restore --encrypt-key 8ABB1A41 --sign-key
8ABB1A41 --ignore-errors --verbosity 9
file:///media/Poodle/backup//media/MadDog/Archive// /media/Poodle/restore/
Linux SOUTH 2.6.32-27-generic #49-Ubuntu SMP Thu Dec 2 00:51:09 UTC 2010
x86_64
/usr/bin/python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3]
================================================================================
Using temporary directory /tmp/duplicity-ku5lKg-tempdir
Registering (mkstemp) temporary file /tmp/duplicity-ku5lKg-tempdir/mkstemp-
MP77AK-1
Temp has 136185794560 available, backup will use approx 34078720.
Synchronizing remote metadata to local cache...
Copying duplicity-full-signatures.20110205T061747Z.sigtar to local cache.
Registering (mktemp) temporary file /tmp/duplicity-ku5lKg-tempdir/mktemp-
stjUrp-2
Deleting /tmp/duplicity-ku5lKg-tempdir/mktemp-stjUrp-2
Forgetting temporary file /tmp/duplicity-ku5lKg-tempdir/mktemp-stjUrp-2
Copying duplicity-full.20110205T061747Z.manifest to local cache.
Registering (mktemp) temporary file /tmp/duplicity-ku5lKg-tempdir/mktemp-
orBhm3-3
Deleting /tmp/duplicity-ku5lKg-tempdir/mktemp-orBhm3-3
Forgetting temporary file /tmp/duplicity-ku5lKg-tempdir/mktemp-orBhm3-3
4776 files exist on backend
2 files exist in cache
.
.
.
Writing Photo Archive/1995/19950817 Fort Lauderdale 07.jpg of type reg
Writing Photo Archive/1995/19950817 Fort Lauderdale 08.jpg of type reg
Removing still remembered temporary file /tmp/duplicity-ku5lKg-
tempdir/mkstemp-MP77AK-1
Removing still remembered temporary file /tmp/duplicity-ku5lKg-
tempdir/mktemp-VgFZYz-585
GPG error detail: Traceback (most recent call last):
  File "/usr/local/bin/duplicity", line 1245, in <module>
    with_tempdir(main)
  File "/usr/local/bin/duplicity", line 1238, in with_tempdir
    fn()
  File "/usr/local/bin/duplicity", line 1192, in main
    restore(col_stats)
  File "/usr/local/bin/duplicity", line 539, in restore
    restore_get_patched_rop_iter(col_stats)):
  File "/usr/local/lib/python2.6/dist-packages/duplicity/patchdir.py", line
522, in Write_ROPaths
    ITR( ropath.index, ropath )
  File "/usr/local/lib/python2.6/dist-packages/duplicity/lazy.py", line
335, in __call__
    last_branch.fast_process, args)
  File "/usr/local/lib/python2.6/dist-packages/duplicity/robust.py", line
37, in check_common_error
    return function(*args)
  File "/usr/local/lib/python2.6/dist-packages/duplicity/patchdir.py", line
575, in fast_process
    ropath.copy( self.base_path.new_index( index ) )
  File "/usr/local/lib/python2.6/dist-packages/duplicity/path.py", line
416, in copy
    other.writefileobj(self.open("rb"))
  File "/usr/local/lib/python2.6/dist-packages/duplicity/path.py", line
591, in writefileobj
    buf = fin.read(_copy_blocksize)
  File "/usr/local/lib/python2.6/dist-packages/duplicity/patchdir.py", line
200, in read
    if not self.addtobuffer():
  File "/usr/local/lib/python2.6/dist-packages/duplicity/patchdir.py", line
225, in addtobuffer
    self.tarinfo_list[0] = self.tar_iter.next()
  File "/usr/local/lib/python2.6/dist-packages/duplicity/patchdir.py", line
332, in next
    self.set_tarfile()
  File "/usr/local/lib/python2.6/dist-packages/duplicity/patchdir.py", line
320, in set_tarfile
    assert not self.current_fp.close()
  File "/usr/local/lib/python2.6/dist-packages/duplicity/dup_temp.py", line
210, in close
    assert not self.fileobj.close()
  File "/usr/local/lib/python2.6/dist-packages/duplicity/gpg.py", line 198,
in close
    self.gpg_failed()
  File "/usr/local/lib/python2.6/dist-packages/duplicity/gpg.py", line 165,
in gpg_failed
    raise GPGError, msg
GPGError: GPG Failed, see log below:
===== Begin GnuPG log =====
gpg: encrypted with 2048-bit RSA key, ID 73B4F60A, created 2010-09-02
"Firstname Lastname(Duplicity key) <name@gmail.com>"
gpg: fatal: zlib inflate problem: incorrect data check
secmem usage: 2624/5664 bytes in 6/16 blocks of pool 5856/32768
===== End GnuPG log =====

I am willing to provide access to the appropriate engineer if required.
The bug has delayed me over a year from using Duplicity, but now that Mozy
is jacking up their rates time to resolution is more critical.

Thanks,
-W
```

Story points: 14.0