[chronojump] External DB change checks if path to chronojump.db is ok



commit e5e37cb06d3757ef048702aeb5fe6c4083313da3
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jun 17 12:48:10 2022 +0200

    External DB change checks if path to chronojump.db is ok

 src/gui/networks.cs | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index cf34132c9..ca2315c0d 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -409,17 +409,21 @@ public partial class ChronoJumpWindow
 
                if (database_fc.Run() == (int)ResponseType.Accept)
                {
-                       // 1) update to config file (to be opened again on next boot)
-
-                       // 2) reassing configChronojump.LastDBFullPath
-                       configChronojump.LastDBFullPath = database_fc.Filename;
+                       // 1) check that there is a database/chronojump.db inside
+                       if ( ! File.Exists( System.IO.Path.Combine (database_fc.Filename, "database", 
"chronojump.db")) )
+                       {
+                               new DialogMessage (Constants.MessageTypes.WARNING,
+                                               "Error: Need to select a folder that has a \"database\" 
folder inside an a \"chronojump.db\" file inside.");
+                       } else {
+                               // 2) reassing configChronojump.LastDBFullPath
+                               configChronojump.LastDBFullPath = database_fc.Filename;
 
-                       // 3) update config file (taking care of being default config file)
-                       configChronojump.UpdateFieldEnsuringDefaultConfigFile ("LastDBFullPath", 
database_fc.Filename);
+                               // 3) update config file (taking care of being default config file)
+                               configChronojump.UpdateFieldEnsuringDefaultConfigFile ("LastDBFullPath", 
database_fc.Filename);
 
-                       // 4) change database
-                       //TODO: think where to put a try/catch, eg if there is no database file, or search 
database/chronojump.db before
-                       databaseChange ();
+                               // 4) change database
+                               databaseChange ();
+                       }
                }
 
                database_fc.Hide ();


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