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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to delete temporary file automatically #256

Open
zmcNotafraid opened this issue Jun 12, 2018 · 3 comments · May be fixed by #285
Open

How to delete temporary file automatically #256

zmcNotafraid opened this issue Jun 12, 2018 · 3 comments · May be fixed by #285

Comments

@zmcNotafraid
Copy link

I use local adapter and transform like this

  def transform(:file_format, _) do
    {:convert, "-format png", :png}
  end

Then I found it will generate a temporary file in temp folder.And I read the code in convert.ex and find this

    new_path = Arc.File.generate_temporary_path(file)

So I need to delete them manually. Do there have any solution to delete them automatically after upload successfully?

@zmcNotafraid zmcNotafraid changed the title How to delete transform method generate temporary file How to delete temporary file automatically Jun 12, 2018
@zmcNotafraid
Copy link
Author

zmcNotafraid commented Jun 13, 2018

I read the code that it invoke System.tmp_dir() method.

tmp_dir()
Writable temporary directory.

Returns a writable temporary directory. Searches for directories in the following order:

the directory named by the TMPDIR environment variable
the directory named by the TEMP environment variable
the directory named by the TMP environment variable
C:\TMP on Windows or /tmp on Unix
as a last resort, the current working directory
Returns nil if none of the above are writable.

So I export TMPDIR=/tmp/imagemagick. The temp file will save in this folder.And you need to delete them manually.

@tielur
Copy link

tielur commented Oct 1, 2018

Any update on this? I'm seeing temporary files being left behind as well when using transform with convert

def transform(:thumb, _) do
  convert_opts =
    "-strip -thumbnail 250x250> -gravity center -background none -extent 250x250 -format png"

  {:convert, convert_opts, :png}
end

@nicholasjhenry
Copy link

nicholasjhenry commented Mar 25, 2019

I have a fork (master...hollar:hollar) that I'm maintaining that removes temporary files after processing. We were processing a large number of files in a small amount of time which ended up flooding the tmp directory. I can clean this up and create a PR if @stavro feels that this approach is the way to go. I'm also open to suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants