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);
            }
        }
 protected void Release(AbstractPersistentStorage storage)
 {
     lock (_primaryStorageAccessLock)
     {
         if (storage.ReleaseRefUnsafe())
         {
             storage.Close();
         }
     }
 }
示例#3
0
 private void Release(AbstractPersistentStorage storage)
 {
     lock (_lookupAccessLock)
     {
         if (storage.ReleaseRefUnsafe())
         {
             _lookup.Remove(storage.SolutionFilePath);
             storage.Close();
         }
     }
 }