<commit_before>﻿using System;
using System.IO;
using System.Linq;
using Microsoft.SqlServer.Management.Smo;

namespace DatabaseMinder
{
    public static class RestoreDatabase
    {
        public static void RestoreDatabaseFromFolder(Server server, string databaseName, string backupFolderPath, string saveMdfFolder)
        {
            Consoler.Write(backupFolderPath);
            foreach (var file in Directory.EnumerateFiles(backupFolderPath, "*.bak").OrderBy(x => x))
            {
                try
                {
                    Consoler.Write(file);
                    Execute(server, databaseName, file, saveMdfFolder);
                }
                catch (Exception ex)
                {
                    Consoler.Warn("bak restore failed", backupFolderPath);
                    Consoler.Error(ex.ToString());
                }
            }
        }

        public static void Execute(Server server, string databaseName, string bakFile, string saveMdfFolder)
        {<commit_msg>Rethrow error<commit_after>﻿using System;
using System.IO;
using System.Linq;
using Microsoft.SqlServer.Management.Smo;

namespace DatabaseMinder
{
    public static class RestoreDatabase
    {
        public static void RestoreDatabaseFromFolder(Server server, string databaseName, string backupFolderPath, string saveMdfFolder)
        {
            Consoler.Write(backupFolderPath);
            foreach (var file in Directory.EnumerateFiles(backupFolderPath, "*.bak").OrderBy(x => x))
            {
                try
                {
                    Consoler.Write(file);
                    Execute(server, databaseName, file, saveMdfFolder);
                }
                catch (Exception ex)
                {
                    Consoler.Warn("bak restore failed", backupFolderPath);
                    Consoler.Error(ex.ToString());
                    throw;
                }
            }
        }

        public static void Execute(Server server, string databaseName, string bakFile, string saveMdfFolder)
        {
{'fraction_non_alphanumeric': 0.07737226277372262, 'fraction_numerical': 0.0, 'mean_word_length': 1.797278911564626, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3578585', 'n_tokens_mistral': 513, 'n_tokens_neox': 487, 'n_words': 118}