Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport 'Deletion of leftovers ZIP files in tmp directory' to v0.26 #11898

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions decidim-core/app/jobs/decidim/data_portability_export_job.rb
Expand Up @@ -13,6 +13,9 @@ def perform(user, export_format = ::Decidim::DataPortabilityExporter::DEFAULT_EX
save_or_upload_file(user, path)

ExportMailer.data_portability_export(user, filename, password).deliver_later

# Deletes temporary file
File.delete(path)
end

private
Expand Down
12 changes: 12 additions & 0 deletions decidim-core/spec/jobs/decidim/data_portability_export_job_spec.rb
Expand Up @@ -16,5 +16,17 @@ module Decidim
expect(email.subject).to include("export")
expect(email.body.encoded).to match("Download")
end

it "deletes the temporary file after finishing the job" do
user = create(:user)

expect(File).to receive(:delete) do |path|
expect(path.to_s).to match(%r{tmp/[a-zA-Z0-9_-]+\.zip})
end

described_class.perform_now(user)

expect(user.data_portability_file.attached?).to be(true)
end
end
end