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
=== modified file 'deja-dup/monitor/monitor.vala'
--- deja-dup/monitor/monitor.vala 2014-05-04 22:01:18 +0000
+++ deja-dup/monitor/monitor.vala 2015-11-10 22:04:18 +0000
@@ -175,26 +175,9 @@
175 // Don't run right now if an instance is already running175 // Don't run right now if an instance is already running
176 if (pid == (Pid)0 && !op_active) {176 if (pid == (Pid)0 && !op_active) {
177 try {177 try {
178 string[] argv = new string[8];
179 int i = 0;
180
181 debug("Running automatic backup.");178 debug("Running automatic backup.");
182179 var command = DejaDup.nice_prefix("deja-dup --backup --auto");
183 if (Environment.find_program_in_path("nice") != null)180 string[] argv = command.split(" ");
184 argv[i++] = "nice";
185
186 if (Environment.find_program_in_path("ionice") != null) {
187 // lowest priority in best-effort class
188 // (can't use idle class as normal user on <2.6.25)
189 argv[i++] = "ionice";
190 argv[i++] = "-c2";
191 argv[i++] = "-n7";
192 }
193
194 argv[i++] = "deja-dup";
195 argv[i++] = "--backup";
196 argv[i++] = "--auto";
197 argv[i++] = null;
198181
199 if (DejaDup.in_testing_mode()) {182 if (DejaDup.in_testing_mode()) {
200 // fake successful and schedule next run183 // fake successful and schedule next run
201184
=== modified file 'libdeja/CommonUtils.vala'
--- libdeja/CommonUtils.vala 2013-10-15 04:36:06 +0000
+++ libdeja/CommonUtils.vala 2015-11-10 22:04:18 +0000
@@ -101,11 +101,9 @@
101 (major == req_major && minor == req_minor && micro >= req_micro);101 (major == req_major && minor == req_minor && micro >= req_micro);
102}102}
103103
104public void run_deja_dup(string args, AppLaunchContext? ctx = null,104public string nice_prefix(string command)
105 List<File>? files = null)
106{105{
107 var cmd = "deja-dup %s".printf(args);106 var cmd = command;
108
109 int major, minor, micro;107 int major, minor, micro;
110 var utsname = Posix.utsname();108 var utsname = Posix.utsname();
111 parse_version(utsname.release, out major, out minor, out micro);109 parse_version(utsname.release, out major, out minor, out micro);
@@ -127,6 +125,13 @@
127 else if (Environment.find_program_in_path("nice") != null)125 else if (Environment.find_program_in_path("nice") != null)
128 cmd = "nice -n19 " + cmd;126 cmd = "nice -n19 " + cmd;
129127
128 return cmd;
129}
130
131public void run_deja_dup(string args, AppLaunchContext? ctx = null,
132 List<File>? files = null)
133{
134 var cmd = nice_prefix("deja-dup %s".printf(args));
130 var flags = AppInfoCreateFlags.SUPPORTS_STARTUP_NOTIFICATION |135 var flags = AppInfoCreateFlags.SUPPORTS_STARTUP_NOTIFICATION |
131 AppInfoCreateFlags.SUPPORTS_URIS;136 AppInfoCreateFlags.SUPPORTS_URIS;
132 try {137 try {

Subscribers

People subscribed via source and target branches