Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
defmodule Plausible.File do
@moduledoc """
File helpers for Plausible.
"""
@doc """
Moves a file from one location to another.
Tries renaming first, and falls back to copying and deleting the original.
"""
@spec mv!(Path.t(), Path.t()) :: :ok
def mv!(source, destination) do
File.rename!(source, destination)
rescue
e in File.RenameError ->
try do
case e.reason do
# fallback to cp/rm for cross-device moves
# https://github.com/plausible/analytics/issues/4638
:exdev -> File.cp!(source, destination)
_ -> reraise(e, __STACKTRACE__)
end
after
File.rm(source)
end
end
end