[chronojump] Close session before compress (to not have chronojump.db busy (and not compressed) on windows)



commit bb0a3836723ce6ac7b0978e700abb020a93ab433
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Oct 4 15:10:16 2022 +0200

    Close session before compress (to not have chronojump.db busy (and not compressed) on windows)

 src/gui/app1/session/export.cs | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/src/gui/app1/session/export.cs b/src/gui/app1/session/export.cs
index de7b21c55..45e732b48 100644
--- a/src/gui/app1/session/export.cs
+++ b/src/gui/app1/session/export.cs
@@ -104,6 +104,7 @@ public partial class ChronoJumpWindow
                                app1s_uc = new UtilCopy(currentSession.UniqueID, false);
 
                                cancelExport = false;
+                               needToCloseSessionToCompress = false;
                                app1s_threadExport = new Thread(new ThreadStart(app1s_export));
                                GLib.Idle.Add (new GLib.IdleHandler (app1s_ExportPulseGTK));
 
@@ -121,14 +122,26 @@ public partial class ChronoJumpWindow
 
        private bool app1s_ExportPulseGTK ()
        {
+               if (exportImportCompressed && needToCloseSessionToCompress)
+               {
+                       LogB.Information("calling reloadSession on compress");
+                       reloadSession ();
+                       LogB.Information("called reloadSession on compress");
+
+                       needToCloseSessionToCompress = false;
+               }
+
                if ( ! app1s_threadExport.IsAlive )
                {
                        LogB.ThreadEnding();
                        app1s_ExportPulseEnd();
 
-                       LogB.Information("calling reloadSession");
-                       reloadSession(); //to use default db again
-                       LogB.Information("called reloadSession");
+                       if (! exportImportCompressed)
+                       {
+                               LogB.Information("calling reloadSession on thread end");
+                               reloadSession(); //to use default db again
+                               LogB.Information("called reloadSession on thread end");
+                       }
 
                        //but unsensitivize left menu
                        vbox_menu_tiny_menu.Sensitive = false;
@@ -190,6 +203,7 @@ public partial class ChronoJumpWindow
                        app1s_uc = new UtilCopy(currentSession.UniqueID, false);
 
                        cancelExport = false;
+                       needToCloseSessionToCompress = false;
                        app1s_threadExport = new Thread(new ThreadStart(app1s_export));
                        GLib.Idle.Add (new GLib.IdleHandler (app1s_ExportPulseGTK));
 
@@ -204,6 +218,7 @@ public partial class ChronoJumpWindow
        }
 
        private const bool exportImportCompressed = true;
+       private static bool needToCloseSessionToCompress;
        static string app1s_exportText;
        static long app1s_exportElapsedMs;
        //No GTK here!
@@ -252,6 +267,10 @@ public partial class ChronoJumpWindow
 
                if (exportImportCompressed)
                {
+                       needToCloseSessionToCompress = true;
+                       while (needToCloseSessionToCompress)
+                               ;
+
                        //compressing with 7z
                        app1s_exportText = string.Format("Compressing …");
                        List<string> parameters = new List<string>();


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