Merge lp:~mterry/deja-dup/tempdir-archive-dir into lp:deja-dup/26

Proposed by Michael Terry
Status: Merged
Merged at revision: 1445
Proposed branch: lp:~mterry/deja-dup/tempdir-archive-dir
Merge into: lp:deja-dup/26
Prerequisite: lp:~mterry/deja-dup/more-idle
Diff against target: 104 lines (+19/-26)
4 files modified
tests/mock/duplicity (+2/-1)
tests/runner.vala (+1/-2)
tools/duplicity/DuplicityInstance.vala (+4/-6)
tools/duplicity/DuplicityJob.vala (+12/-17)
To merge this branch: bzr merge lp:~mterry/deja-dup/tempdir-archive-dir
Reviewer Review Type Date Requested Status
Robert Bruce Park (community) Needs Fixing
Review via email: mp+155323@code.launchpad.net

This proposal supersedes a proposal from 2013-03-25.

Description of the change

A little while back, for 25.5, I added code to tell duplicity to use a tempdir that is on the same partition as the source files, so that a user with /tmp as a tmpfs partition wouldn't fill it up.

However, there is one code path where we end up using /tmp anyway, that I didn't notice. If we are testing a restore in "nag mode", which is where we don't use any cached information (we re-download all the metadata and ask for the password again, hence the "nag"), we were making a call to g_dir_make_tmp. This uses /tmp, and we were filling /tmp up with our downloaded metadata.

So the solution is to use g_mkdtemp, which lets us specify a tempdir, and we'll re-use the one we create for passing to duplicity.

There's a bit of cleanup in the tests/ directory to match this new usage and to better test it.

To post a comment you must log in.
1446. By Michael Terry

use duplicity-XXXXXX instead of deja-dup-XXXXXX so that we will clean the folder automatically

Revision history for this message
Robert Bruce Park (robru) wrote :

So, the diff looks quite nice, but 'make check' failed with this error:

/scripts/instance-error: OK
/scripts/mkdir: OK
/scripts/nag:
** (/home/robru/Applications/deja-dup/tempdir-archive-dir/tests/.libs/lt-runner:4911): WARNING **: runner.vala:292: Error string didn't match; expected (null), got Failed with an unknown error.
/bin/bash: line 1: 4911 Trace/breakpoint trap (core dumped) top_builddir=.. srcdir=. dbus-launch ./runner $test
make[1]: *** [check] Error 133
make[1]: Leaving directory `/home/robru/Applications/deja-dup/tempdir-archive-dir/tests'
make: *** [check-recursive] Error 1

review: Needs Fixing
Revision history for this message
Michael Terry (mterry) wrote :

Ah, whoops. That was because of my second commit. I forgot to update the test to account for the change. Fixing that is just test-side and does not change the logic of the merge, so I'll just go ahead and merge.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/mock/duplicity'
2--- tests/mock/duplicity 2012-10-30 00:19:38 +0000
3+++ tests/mock/duplicity 2013-03-25 20:12:23 +0000
4@@ -108,7 +108,8 @@
5 if split[1].find("/cache/") != -1:
6 print("TESTFAIL: expected random /tmp archive dir", file=logfd)
7 sys.exit(-1)
8- sys.argv[i] = "--archive-dir=?"
9+ # Chop off random string at end, for reproducable tests
10+ sys.argv[i] = sys.argv[i][:-6] + "?"
11
12 if expected_args != sys.argv[1:]:
13 print("TESTFAIL: expected\n%s\nvs\n%s" % (expected_args, sys.argv[1:]), file=logfd)
14
15=== modified file 'tests/runner.vala'
16--- tests/runner.vala 2013-02-04 20:39:45 +0000
17+++ tests/runner.vala 2013-03-25 20:12:23 +0000
18@@ -140,13 +140,12 @@
19 var backupdir = Path.build_filename(test_home, "backup");
20 var restoredir = Path.build_filename(test_home, "restore");
21
22- var archive = tmp_archive ? "?" : "%s/deja-dup".printf(cachedir);
23-
24 string enc_str = "";
25 if (!encrypted)
26 enc_str = "--no-encryption ";
27
28 var tempdir = Path.build_filename(test_home, "tmp");
29+ var archive = tmp_archive ? "%s/deja-dup-?".printf(tempdir) : "%s/deja-dup".printf(cachedir);
30
31 var end_str = "%s'--verbosity=9' '--gpg-options=--no-use-agent' '--archive-dir=%s' '--tempdir=%s' '%s'".printf(enc_str, archive, tempdir, make_fd_arg(as_root));
32
33
34=== modified file 'tools/duplicity/DuplicityInstance.vala'
35--- tools/duplicity/DuplicityInstance.vala 2013-01-24 14:31:08 +0000
36+++ tools/duplicity/DuplicityInstance.vala 2013-03-25 20:12:23 +0000
37@@ -93,12 +93,10 @@
38 // Cache signature files
39 var cache_dir = forced_cache_dir;
40 if (cache_dir == null)
41- cache_dir = Environment.get_user_cache_dir();
42- if (cache_dir != null) {
43- cache_dir = Path.build_filename(cache_dir, Config.PACKAGE);
44- if (DejaDup.ensure_directory_exists(cache_dir))
45- argv.append("--archive-dir=" + cache_dir);
46- }
47+ cache_dir = Path.build_filename(Environment.get_user_cache_dir(),
48+ Config.PACKAGE);
49+ if (cache_dir != null && DejaDup.ensure_directory_exists(cache_dir))
50+ argv.append("--archive-dir=" + cache_dir);
51
52 // Specify tempdir
53 var tempdir = yield DejaDup.get_tempdir();
54
55=== modified file 'tools/duplicity/DuplicityJob.vala'
56--- tools/duplicity/DuplicityJob.vala 2013-01-20 19:54:44 +0000
57+++ tools/duplicity/DuplicityJob.vala 2013-03-25 20:12:23 +0000
58@@ -110,9 +110,6 @@
59
60 ~DuplicityJob() {
61 DejaDup.Network.get().notify["connected"].disconnect(network_changed);
62-
63- if (forced_cache_dir != null)
64- new DejaDup.RecursiveDelete(File.new_for_path(forced_cache_dir)).start_async.begin();
65 }
66
67 public override void start()
68@@ -130,24 +127,22 @@
69 if (mode == DejaDup.ToolJob.Mode.BACKUP)
70 process_include_excludes();
71
72+ var settings = DejaDup.get_settings();
73+ delete_age = settings.get_int(DejaDup.DELETE_AFTER_KEY);
74+
75+ async_setup.begin();
76+ }
77+
78+ async void async_setup()
79+ {
80 /* Fake cache dir if we need to */
81 if ((flags & DejaDup.ToolJob.Flags.NO_CACHE) != 0) {
82- try {
83- forced_cache_dir = DirUtils.make_tmp("deja-dup-XXXXXX");
84- }
85- catch (Error e) {
86- warning("%s\n", e.message);
87- }
88+ /* Look like a duplicity tempdir so that clean_tempdirs will clean this for us */
89+ var template = Path.build_filename(yield DejaDup.get_tempdir(), "duplicity-XXXXXX");
90+ forced_cache_dir = DirUtils.mkdtemp(template);
91 }
92
93- var settings = DejaDup.get_settings();
94- delete_age = settings.get_int(DejaDup.DELETE_AFTER_KEY);
95-
96- get_envp.begin();
97- }
98-
99- async void get_envp()
100- {
101+ /* Get custom environment from backend, if needed */
102 try {
103 backend.envp_ready.connect(continue_with_envp);
104 yield backend.get_envp();

Subscribers

People subscribed via source and target branches