Merge lp:~naufraghi/deja-dup/nice-monitor into lp:deja-dup/34

Proposed by Matteo Bertini
Status: Merged
Merged at revision: 1550
Proposed branch: lp:~naufraghi/deja-dup/nice-monitor
Merge into: lp:deja-dup/34
Diff against target: 64 lines (+11/-23)
2 files modified
deja-dup/monitor/monitor.vala (+2/-19)
libdeja/CommonUtils.vala (+9/-4)
To merge this branch: bzr merge lp:~naufraghi/deja-dup/nice-monitor
Reviewer Review Type Date Requested Status
Michael Terry Approve
Review via email: mp+277190@code.launchpad.net

Description of the change

This patche factorizes a common `nice_prefix` function in CommonUtils.vala and uses it both from utils and from monitor.vala

The old code in monitor was using an hardcoded legacy nice values and was never as idle as the new utils code.

Warning. These are my first lines in vala

To post a comment you must log in.
Revision history for this message
Matteo Bertini (naufraghi) wrote :

Comments?

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

Sorry for late reply. This looks great, thank you! I had totally forgot we had a second nice check in monitor.vala. :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'deja-dup/monitor/monitor.vala'
2--- deja-dup/monitor/monitor.vala 2014-05-04 22:01:18 +0000
3+++ deja-dup/monitor/monitor.vala 2015-11-10 22:04:18 +0000
4@@ -175,26 +175,9 @@
5 // Don't run right now if an instance is already running
6 if (pid == (Pid)0 && !op_active) {
7 try {
8- string[] argv = new string[8];
9- int i = 0;
10-
11 debug("Running automatic backup.");
12-
13- if (Environment.find_program_in_path("nice") != null)
14- argv[i++] = "nice";
15-
16- if (Environment.find_program_in_path("ionice") != null) {
17- // lowest priority in best-effort class
18- // (can't use idle class as normal user on <2.6.25)
19- argv[i++] = "ionice";
20- argv[i++] = "-c2";
21- argv[i++] = "-n7";
22- }
23-
24- argv[i++] = "deja-dup";
25- argv[i++] = "--backup";
26- argv[i++] = "--auto";
27- argv[i++] = null;
28+ var command = DejaDup.nice_prefix("deja-dup --backup --auto");
29+ string[] argv = command.split(" ");
30
31 if (DejaDup.in_testing_mode()) {
32 // fake successful and schedule next run
33
34=== modified file 'libdeja/CommonUtils.vala'
35--- libdeja/CommonUtils.vala 2013-10-15 04:36:06 +0000
36+++ libdeja/CommonUtils.vala 2015-11-10 22:04:18 +0000
37@@ -101,11 +101,9 @@
38 (major == req_major && minor == req_minor && micro >= req_micro);
39 }
40
41-public void run_deja_dup(string args, AppLaunchContext? ctx = null,
42- List<File>? files = null)
43+public string nice_prefix(string command)
44 {
45- var cmd = "deja-dup %s".printf(args);
46-
47+ var cmd = command;
48 int major, minor, micro;
49 var utsname = Posix.utsname();
50 parse_version(utsname.release, out major, out minor, out micro);
51@@ -127,6 +125,13 @@
52 else if (Environment.find_program_in_path("nice") != null)
53 cmd = "nice -n19 " + cmd;
54
55+ return cmd;
56+}
57+
58+public void run_deja_dup(string args, AppLaunchContext? ctx = null,
59+ List<File>? files = null)
60+{
61+ var cmd = nice_prefix("deja-dup %s".printf(args));
62 var flags = AppInfoCreateFlags.SUPPORTS_STARTUP_NOTIFICATION |
63 AppInfoCreateFlags.SUPPORTS_URIS;
64 try {

Subscribers

People subscribed via source and target branches