X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=inline;f=lib%2Fpleroma%2Fotp_version.ex;h=a5ac1b07277d5569981c7938c77f2bdd3f3107fc;hb=fc42e714e234542bfec5a53a3fb9b7a45bcb4bd3;hp=54ceaff479ba6baf9186257e85654ab56a0812c8;hpb=4c8569d403f47957f7a5d698c595959007c8a95a;p=akkoma
diff --git a/lib/pleroma/otp_version.ex b/lib/pleroma/otp_version.ex
index 54ceaff47..a5ac1b072 100644
--- a/lib/pleroma/otp_version.ex
+++ b/lib/pleroma/otp_version.ex
@@ -1,53 +1,28 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.OTPVersion do
- @type check_status() :: :ok | :undefined | {:error, String.t()}
-
- @spec check() :: check_status()
- def check do
+ @spec version() :: String.t() | nil
+ def version do
# OTP Version https://erlang.org/doc/system_principles/versions.html#otp-version
[
Path.join(:code.root_dir(), "OTP_VERSION"),
Path.join([:code.root_dir(), "releases", :erlang.system_info(:otp_release), "OTP_VERSION"])
]
|> get_version_from_files()
- |> do_check()
- end
-
- @spec check([Path.t()]) :: check_status()
- def check(paths) do
- paths
- |> get_version_from_files()
- |> do_check()
end
- defp get_version_from_files([]), do: nil
+ @spec get_version_from_files([Path.t()]) :: String.t() | nil
+ def get_version_from_files([]), do: nil
- defp get_version_from_files([path | paths]) do
+ def get_version_from_files([path | paths]) do
if File.exists?(path) do
- File.read!(path)
+ path
+ |> File.read!()
+ |> String.replace(~r/\r|\n|\s/, "")
else
get_version_from_files(paths)
end
end
-
- defp do_check(nil), do: :undefined
-
- defp do_check(version) do
- version = String.replace(version, ~r/\r|\n|\s/, "")
-
- [major, minor] =
- version
- |> String.split(".")
- |> Enum.map(&String.to_integer/1)
- |> Enum.take(2)
-
- if (major == 22 and minor >= 2) or major > 22 do
- :ok
- else
- {:error, version}
- end
- end
end