projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
OTP release install guide sceleton
[akkoma]
/
lib
/
pleroma
/
flake_id.ex
diff --git
a/lib/pleroma/flake_id.ex
b/lib/pleroma/flake_id.ex
index 69ab8ccf929f10184968a009f76fce5aa3384392..58ab3650dc952de4465c30a77cbcf78f06b11e66 100644
(file)
--- a/
lib/pleroma/flake_id.ex
+++ b/
lib/pleroma/flake_id.ex
@@
-27,7
+27,7
@@
defmodule Pleroma.FlakeId do
Kernel.to_string(id)
end
Kernel.to_string(id)
end
- def to_string(
flake = <<_::integer-size(64), _::integer-size(48), _::integer-size(16)>>
) do
+ def to_string(
<<_::integer-size(64), _::integer-size(48), _::integer-size(16)>> = flake
) do
encode_base62(flake)
end
encode_base62(flake)
end
@@
-42,11
+42,11
@@
defmodule Pleroma.FlakeId do
def from_string(unquote(Kernel.to_string(i))), do: <<0::integer-size(128)>>
end
def from_string(unquote(Kernel.to_string(i))), do: <<0::integer-size(128)>>
end
- def from_string(
flake = <<_::integer-size(128)>>
), do: flake
+ def from_string(
<<_::integer-size(128)>> = flake
), do: flake
def from_string(string) when is_binary(string) and byte_size(string) < 18 do
case Integer.parse(string) do
def from_string(string) when is_binary(string) and byte_size(string) < 18 do
case Integer.parse(string) do
- {id,
_
} -> <<0::integer-size(64), id::integer-size(64)>>
+ {id,
""
} -> <<0::integer-size(64), id::integer-size(64)>>
_ -> nil
end
end
_ -> nil
end
end
@@
-85,7
+85,7
@@
defmodule Pleroma.FlakeId do
{:ok, FlakeId.from_string(value)}
end
{:ok, FlakeId.from_string(value)}
end
- def autogenerate
()
, do: get()
+ def autogenerate, do: get()
# -- GenServer API
def start_link do
# -- GenServer API
def start_link do
@@
-165,7
+165,7
@@
defmodule Pleroma.FlakeId do
1_000_000_000 * mega_seconds + seconds * 1000 + :erlang.trunc(micro_seconds / 1000)
end
1_000_000_000 * mega_seconds + seconds * 1000 + :erlang.trunc(micro_seconds / 1000)
end
- defp worker_id
()
do
+ defp worker_id do
<<worker::integer-size(48)>> = :crypto.strong_rand_bytes(6)
worker
end
<<worker::integer-size(48)>> = :crypto.strong_rand_bytes(6)
worker
end