예제 #1
0
        private bool TryCreatePersistentStorage(
            Solution solution,
            string workingFolderPath,
            out IChecksummedPersistentStorage persistentStorage)
        {
            persistentStorage = null;

            var databaseFilePath = GetDatabaseFilePath(workingFolderPath);

            try
            {
                if (!TryOpenDatabase(solution, workingFolderPath, databaseFilePath, out persistentStorage))
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                StorageDatabaseLogger.LogException(ex);

                if (ShouldDeleteDatabase(ex))
                {
                    // this was not a normal exception that we expected during DB open.
                    // Report this so we can try to address whatever is causing this.
                    FatalError.ReportWithoutCrash(ex);
                    IOUtilities.PerformIO(() => Directory.Delete(Path.GetDirectoryName(databaseFilePath), recursive: true));
                }

                return(false);
            }
        }
        private bool TryCreatePersistentStorage(
            Solution solution, string workingFolderPath,
            out AbstractPersistentStorage persistentStorage)
        {
            persistentStorage = null;
            AbstractPersistentStorage database = null;

            try
            {
                database = OpenDatabase(solution, workingFolderPath);
                database.Initialize(solution);

                persistentStorage = database;
                return(true);
            }
            catch (Exception ex)
            {
                StorageDatabaseLogger.LogException(ex);

                if (database != null)
                {
                    database.Close();
                }

                if (ShouldDeleteDatabase(ex))
                {
                    // this was not a normal exception that we expected during DB open.
                    // Report this so we can try to address whatever is causing this.
                    FatalError.ReportWithoutCrash(ex);
                    IOUtilities.PerformIO(() => Directory.Delete(database.DatabaseDirectory, recursive: true));
                }

                return(false);
            }
        }