mirror of
https://github.com/linuxmint/timeshift.git
synced 2024-09-11 17:07:43 +03:00
Terminate rsync when user closes main window
This commit is contained in:
parent
49de846a01
commit
245472985e
@ -2437,6 +2437,30 @@ public class Main : GLib.Object{
|
||||
|
||||
//Gtk.main_quit ();
|
||||
}
|
||||
|
||||
public bool is_rsync_running(){
|
||||
string cmd = "rsync -ai --delete --numeric-ids --relative --delete-excluded";
|
||||
string txt = execute_command_sync_get_output ("ps w -C rsync");
|
||||
foreach(string line in txt.split("\n")){
|
||||
if (line.index_of(cmd) != -1){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void kill_rsync(){
|
||||
string cmd = "rsync -ai --delete --numeric-ids --relative --delete-excluded";
|
||||
string txt = execute_command_sync_get_output ("ps w -C rsync");
|
||||
string pid = "";
|
||||
foreach(string line in txt.split("\n")){
|
||||
if (line.index_of(cmd) != -1){
|
||||
pid = line.strip().split(" ")[0];
|
||||
Posix.kill ((Pid) int.parse(pid), 15);
|
||||
log_msg(_("Terminating rsync process") + ": [PID=" + pid + "] ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TimeShiftBackup : GLib.Object{
|
||||
|
@ -475,7 +475,12 @@ class MainWindow : Gtk.Window{
|
||||
private bool on_delete_event(Gdk.EventAny event){
|
||||
|
||||
this.delete_event.disconnect(on_delete_event); //disconnect this handler
|
||||
|
||||
|
||||
if (App.is_rsync_running()){
|
||||
log_error (_("Main window closed by user"));
|
||||
App.kill_rsync();
|
||||
}
|
||||
|
||||
if (!App.is_scheduled){
|
||||
return false; //close window
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ namespace TeeJee.Logging{
|
||||
}
|
||||
|
||||
if (LOG_TIMESTAMP){
|
||||
msg += "[" + timestamp() + "] ";
|
||||
msg += timestamp() + " ";
|
||||
}
|
||||
|
||||
msg += message;
|
||||
@ -95,7 +95,7 @@ namespace TeeJee.Logging{
|
||||
}
|
||||
|
||||
if (LOG_TIMESTAMP){
|
||||
msg += "[" + timestamp() + "] ";
|
||||
msg += timestamp() + " ";
|
||||
}
|
||||
|
||||
string prefix = (is_warning) ? _("Warning") : _("Error");
|
||||
|
Loading…
Reference in New Issue
Block a user