Queries with raw SQL

Both the move/3 and rename/3 functions rely on the private _move/4 function, which is able to change simultaneously the full path and filename of a media file:

$ cat apps/elixir_drip/lib/elixir_drip/storage/storage.exdefmodule ElixirDrip.Storage do  # ...  def move(user_id, media_id, new_path),    do: _move(user_id, media_id, new_path, nil)  def rename(user_id, media_id, new_name),    do: _move(user_id, media_id, nil, new_name)  defp _move(user_id, media_id, new_path, new_name), do: ...  # ...end

This _move/4 function only allows the media file creator to change its folder or its filename. Then, it gets the media file, the new path, and filename, and checks whether a file on the new path exists with the new name. If everything went ...

Get Mastering Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.