[chronojump] On backup, delete old backup dir (previous to 2.1.3) if exists.



commit 36bf3e69a0a53083497bde7df7475e36f9d09527
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Aug 20 15:27:13 2021 +0200

    On backup, delete old backup dir (previous to 2.1.3) if exists.

 glade/app1.glade               | 75 +++++++++++++++++++++++++++++-------------
 src/gui/app1/session/backup.cs | 26 +++++++++++++++
 src/gui/app1/session/main.cs   |  3 ++
 3 files changed, 81 insertions(+), 23 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 468c5e925..91085c798 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -25666,6 +25666,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -31977,18 +31980,6 @@ Concentric</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">6</property>
                                                             <child>
-                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
-                                                            <property name="can_focus">False</property>
-                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="pack_type">end</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_capturing">
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">4</property>
@@ -32025,6 +32016,18 @@ Concentric</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="pack_type">end</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_no_capturing">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -41317,6 +41320,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -46479,6 +46485,30 @@ then click this button.</property>
                                                             <property name="position">2</property>
                                                             </packing>
                                                             </child>
+                                                            <child>
+                                                            <widget class="GtkVButtonBox" id="vbuttonbox9">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <child>
+                                                            <widget class="GtkButton" 
id="app1s_button_delete_old_incomplete">
+                                                            <property name="label" translatable="yes">Delete 
old incomplete backups</property>
+                                                            <property name="can_focus">True</property>
+                                                            <property name="receives_default">True</property>
+                                                            <signal name="clicked" 
handler="on_app1s_button_delete_old_incomplete_clicked" swapped="no"/>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="position">3</property>
+                                                            </packing>
+                                                            </child>
                                                             </widget>
                                                             </child>
                                                             <child>
@@ -46777,7 +46807,7 @@ then click this button.</property>
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="label" 
translatable="yes">Versions prior to Chronojump 2.1.3 performed automatic backups at each Chronojump boot but 
did not include the raw data.
-Since Chronojump 2.1.3, scheduled backups contain the complete data.</property>
+Since Chronojump 2.1.3, backups contain the complete data.</property>
                                                             <property name="wrap">True</property>
                                                             </widget>
                                                             <packing>
@@ -46828,11 +46858,12 @@ Since Chronojump 2.1.3, scheduled backups contain the complete data.</property>
                                                             <property name="spacing">20</property>
                                                             <property name="layout_style">center</property>
                                                             <child>
-                                                            <widget class="GtkButton" id="button15">
-                                                            <property name="label" 
translatable="yes">No</property>
+                                                            <widget class="GtkButton" 
id="app1s_button_old_backups_delete_do">
+                                                            <property name="label" translatable="yes">Delete 
them</property>
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="receives_default">True</property>
+                                                            <signal name="clicked" 
handler="on_app1s_button_old_backups_delete_do_clicked" swapped="no"/>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -46840,24 +46871,22 @@ Since Chronojump 2.1.3, scheduled backups contain the complete data.</property>
                                                             <property name="position">0</property>
                                                             </packing>
                                                             </child>
-                                                            <child>
-                                                            <widget class="GtkButton" id="button16">
-                                                            <property name="label" 
translatable="yes">Yes</property>
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">True</property>
-                                                            <property name="receives_default">True</property>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
-                                                            <property name="position">1</property>
+                                                            <property name="position">2</property>
                                                             </packing>
                                                             </child>
+                                                            <child>
+                                                            <widget class="GtkLabel" 
id="app1s_label_old_backups_delete_done">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" 
translatable="yes">Deleted.</property>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
                                                             <property name="fill">False</property>
-                                                            <property name="position">2</property>
+                                                            <property name="position">3</property>
                                                             </packing>
                                                             </child>
                                                             </widget>
diff --git a/src/gui/app1/session/backup.cs b/src/gui/app1/session/backup.cs
index fa0bae08b..15e5a9d17 100644
--- a/src/gui/app1/session/backup.cs
+++ b/src/gui/app1/session/backup.cs
@@ -62,6 +62,7 @@ public partial class ChronoJumpWindow
                app1s_label_backup_progress.Text = "";
                app1s_button_backup_select.Sensitive = true;
                app1s_button_backup_start.Sensitive = false;
+               app1s_button_delete_old_incomplete.Visible = false;
                app1s_button_backup_cancel_close.Sensitive = true;
                app1s_label_backup_cancel_close.Text = Catalog.GetString("Cancel");
 
@@ -311,6 +312,15 @@ public partial class ChronoJumpWindow
                app1s_label_backup_progress.Text =
                        string.Format(Catalog.GetString("Copied in {0} ms"),
                                        app1s_copyRecursiveElapsedMs);
+
+               // show button to delete old backups (if exists)
+               if(Directory.Exists (Util.GetBackupDirOld()))
+               {
+                       int filesBackup, sizeInKBBackup;
+                       Util.GetBackupsSize (out filesBackup, out sizeInKBBackup);
+                       if(filesBackup > 0)
+                               app1s_button_delete_old_incomplete.Visible = true;
+               }
        }
 
        private void app1s_backup_doing_sensitive_start_end(bool start)
@@ -360,6 +370,22 @@ public partial class ChronoJumpWindow
                }
        }
 
+       private void on_app1s_button_delete_old_incomplete_clicked (object o, EventArgs args)
+       {
+               label_backup_why.Visible = false; //do not show again label_backup_why
+               app1s_label_backup_cancel_close.Text = Catalog.GetString("Cancel");
+
+               notebook_session_backup.Page = Convert.ToInt32(notebook_session_backup_pages.DELETE_OLD);
+       }
+       private void on_app1s_button_old_backups_delete_do_clicked (object o, EventArgs args)
+       {
+               Directory.Delete(Util.GetBackupDirOld(), true);
+
+               app1s_button_old_backups_delete_do.Sensitive = false;
+               app1s_label_old_backups_delete_done.Visible = true;
+               app1s_label_backup_cancel_close.Text = Catalog.GetString("Close");
+       }
+
        /*
         * deprecated since 1.6.0. Use backup method below
        */
diff --git a/src/gui/app1/session/main.cs b/src/gui/app1/session/main.cs
index e0a5db7e5..2842a66c3 100644
--- a/src/gui/app1/session/main.cs
+++ b/src/gui/app1/session/main.cs
@@ -169,6 +169,9 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.ProgressBar app1s_pulsebarBackupActivity;
        [Widget] Gtk.ProgressBar app1s_pulsebarBackupDirs;
        [Widget] Gtk.ProgressBar app1s_pulsebarBackupSecondDirs;
+       [Widget] Gtk.Button app1s_button_delete_old_incomplete;
+       [Widget] Gtk.Button app1s_button_old_backups_delete_do;
+       [Widget] Gtk.Label app1s_label_old_backups_delete_done;
        [Widget] Gtk.Button app1s_button_backup_scheduled_remind_tomorrow;
        [Widget] Gtk.Button app1s_button_backup_scheduled_remind_30d;
        [Widget] Gtk.Button app1s_button_backup_scheduled_remind_60d;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]