예제 #1
0
        /* Function: Start
         *
         * Dependencies:
         *
         *		- <Config.Manager> must be started before using the rest of the class.
         */
        public bool Start(Errors.ErrorList errors)
        {
            EngineInstance.AddStartupWatcher(this);

            SQLite.API.Result sqliteResult = SQLite.API.Initialize();

            if (sqliteResult != SQLite.API.Result.OK)
            {
                throw new SQLite.Exceptions.UnexpectedResult("Could not initialize SQLite.", sqliteResult);
            }

            Path databaseFile = EngineInstance.Config.WorkingDataFolder + "/CodeDB.nd";

            connection = new SQLite.Connection();
            bool success = false;

            if (!EngineInstance.HasIssues(StartupIssues.NeedToStartFresh |
                                          StartupIssues.FileIDsInvalidated |
                                          StartupIssues.CodeIDsInvalidated |
                                          StartupIssues.CommentIDsInvalidated))
            {
                try
                {
                    connection.Open(databaseFile, false);

                    Version version = GetVersion();

                    if (BinaryFile.IsCompatible(version, Engine.Instance.Version, "2.0.2") == true)
                    {
                        LoadSystemVariables();
                        success = true;
                    }
                }
                catch { }
            }

            if (!success)
            {
                connection.Dispose();

                if (System.IO.File.Exists(databaseFile))
                {
                    System.IO.File.Delete(databaseFile);
                }

                connection.Open(databaseFile, true);
                CreateDatabase();

                EngineInstance.AddStartupIssues(StartupIssues.CodeIDsInvalidated |
                                                StartupIssues.CommentIDsInvalidated |
                                                StartupIssues.NeedToReparseAllFiles,
                                                dontNotify: this);
            }

            started = true;
            return(true);
        }
예제 #2
0
        /* Function: Start
         *
         * Dependencies:
         *
         *		- <Config.Manager> must be started before using the rest of the class.
         */
        public bool Start(Errors.ErrorList errors)
        {
            SQLite.API.Result sqliteResult = SQLite.API.Initialize();

            if (sqliteResult != SQLite.API.Result.OK)
            {
                throw new SQLite.Exceptions.UnexpectedResult("Could not initialize SQLite.", sqliteResult);
            }

            Path databaseFile = EngineInstance.Config.WorkingDataFolder + "/CodeDB.nd";

            connection = new SQLite.Connection();
            bool success = false;

            if (EngineInstance.Config.ReparseEverything == false)
            {
                try
                {
                    connection.Open(databaseFile, false);

                    Version version = GetVersion();

                    if (Version.BinaryDataCompatibility(version, Engine.Instance.Version, "2.0") == true)
                    {
                        LoadSystemVariables();
                        success = true;
                    }
                }
                catch { }
            }

            if (!success)
            {
                connection.Dispose();

                if (System.IO.File.Exists(databaseFile))
                {
                    System.IO.File.Delete(databaseFile);
                }

                EngineInstance.Config.ReparseEverything = true;
                reparsingEverything = true;

                connection.Open(databaseFile, true);
                CreateDatabase();
            }

            return(true);
        }