Merge lp:~ed.so/duplicity/duplicity.tmpspacefix into lp:duplicity/0.6-series

Proposed by edso on 2012-09-10
Status: Merged
Merged at revision: 860
Proposed branch: lp:~ed.so/duplicity/duplicity.tmpspacefix
Merge into: lp:duplicity/0.6-series
Diff against target: 52 lines (+13/-3)
2 files modified
duplicity/patchdir.py (+7/-3)
duplicity/tempdir.py (+6/-0)
To merge this branch: bzr merge lp:~ed.so/duplicity/duplicity.tmpspacefix
Reviewer Review Type Date Requested Status
duplicity-team 2012-09-10 Pending
Review via email: mp+123622@code.launchpad.net

Description of the change

probably solves bug 'Out of space error while restoring a file' due to creating restored files always in /tmp
see bug tracker/mailing list
 https://bugs.launchpad.net/duplicity/+bug/1005901
 http://lists.gnu.org/archive/html/duplicity-talk/2012-09/msg00000.html

To post a comment you must log in.
860. By edso on 2012-09-11

use tempfile.TemporaryFile() so unused temp files are deleted automagically

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'duplicity/patchdir.py'
2--- duplicity/patchdir.py 2011-08-23 18:14:17 +0000
3+++ duplicity/patchdir.py 2012-09-11 14:13:22 +0000
4@@ -21,8 +21,8 @@
5
6 import re #@UnusedImport
7 import types
8+import os
9 import tempfile
10-import os
11
12 from duplicity import tarfile #@UnusedImport
13 from duplicity import librsync #@UnusedImport
14@@ -30,6 +30,7 @@
15 from duplicity import diffdir
16 from duplicity import misc
17 from duplicity import selection
18+from duplicity import tempdir
19 from duplicity import util #@UnusedImport
20 from duplicity.path import * #@UnusedWildImport
21 from duplicity.lazy import * #@UnusedWildImport
22@@ -470,8 +471,11 @@
23 for delta_ropath in patch_seq[1:]:
24 assert delta_ropath.difftype == "diff", delta_ropath.difftype
25 if not isinstance( current_file, file ):
26- # librsync needs true file
27- tempfp = os.tmpfile()
28+ """
29+ librsync insists on a real file object, which we create manually
30+ by using the duplicity.tempdir to tell us where.
31+ """
32+ tempfp = tempfile.TemporaryFile( dir=tempdir.default().dir() )
33 misc.copyfileobj( current_file, tempfp )
34 assert not current_file.close()
35 tempfp.seek( 0 )
36
37=== modified file 'duplicity/tempdir.py'
38--- duplicity/tempdir.py 2011-08-18 19:17:55 +0000
39+++ duplicity/tempdir.py 2012-09-11 14:13:22 +0000
40@@ -127,6 +127,12 @@
41
42 self.__lock = threading.Lock() # protect private resources *AND* mktemp/mkstemp calls
43
44+ def dir(self):
45+ """
46+ Returns the absolute pathname of the temp folder.
47+ """
48+ return self.__dir
49+
50 def __del__(self):
51 """
52 Perform cleanup.

Subscribers

People subscribed via source and target branches

to all changes: