Fix export being outputted in the wrong directory in release mode

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-11-22 18:43:59 +01:00
parent ed7e6e4d4b
commit 377b83e02d
8 changed files with 48 additions and 20 deletions

View File

@@ -3,17 +3,21 @@ defmodule Mobilizon.Service.Export.Participants.CSV do
Export a list of participants to CSV
"""
alias Mobilizon.Events
alias Mobilizon.{Events, Export}
alias Mobilizon.Events.Event
alias Mobilizon.Export
alias Mobilizon.Storage.Repo
alias Mobilizon.Web.Gettext
import Mobilizon.Web.Gettext, only: [gettext: 2]
import Mobilizon.Service.Export.Participants.Common,
only: [save_upload: 5, columns: 0, to_list: 1, clean_exports: 2, export_enabled?: 1]
@upload_path "uploads/exports/csv/"
only: [
save_upload: 5,
columns: 0,
to_list: 1,
clean_exports: 2,
export_enabled?: 1,
export_path: 1
]
@extension "csv"
@@ -26,7 +30,7 @@ defmodule Mobilizon.Service.Export.Participants.CSV do
def export(%Event{id: event_id} = event, options \\ []) do
if ready?() do
filename = "#{ShortUUID.encode!(Ecto.UUID.generate())}.csv"
full_path = @upload_path <> filename
full_path = Path.join([export_path(@extension), filename])
file = File.open!(full_path, [:write, :utf8])
@@ -80,7 +84,7 @@ defmodule Mobilizon.Service.Export.Participants.CSV do
"""
@spec clean_exports :: :ok
def clean_exports do
clean_exports("csv", @upload_path)
clean_exports("csv", export_path(@extension))
end
@spec dependencies_ok? :: boolean