<commit_before>require "log4r"

module VagrantPlugins
  module HyperV
    module Action
      class ReadState
        def initialize(app, env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant::hyperv::connection")
        end

        def call(env)
          if env[:machine].id
            options = { VmId: env[:machine].id }
            response = env[:machine].provider.driver.execute('get_vm_status.ps1', options)
            env[:machine_state_id] = response["state"].downcase.to_sym
          else
            env[:machine_state_id] = :not_created
          end
          @app.call(env)
        end
      end
    end
  end
end
<commit_msg>providers/hyperv: reset machine ID if machine deleted outside<commit_after>require "log4r"

module VagrantPlugins
  module HyperV
    module Action
      class ReadState
        def initialize(app, env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant::hyperv::connection")
        end

        def call(env)
          if env[:machine].id
            options = { VmId: env[:machine].id }
            response = env[:machine].provider.driver.execute(
              "get_vm_status.ps1", options)
            env[:machine_state_id] = response["state"].downcase.to_sym

            # If the machine isn't created, then our ID is stale, so just
            # mark it as not created.
            if env[:machine_state_id] == :not_created
              env[:machine].id = nil
            end
          else
            env[:machine_state_id] = :not_created
          end
          @app.call(env)
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.09697344039530574, 'fraction_numerical': 0.0037059913526868438, 'mean_word_length': 1.8421052631578947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3008651', 'n_tokens_mistral': 474, 'n_tokens_neox': 466, 'n_words': 111}