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

Use application tmp dir for product import #12649

Merged
merged 4 commits into from
Jul 11, 2024

Commits on Jul 9, 2024

  1. Configuration menu
    Copy the full SHA
    cc1fa7f View commit details
    Browse the repository at this point in the history
  2. Always delete uploaded file on error

    The file path was never going to be 'tmp/product_import', so I guess it never deleted the file.
    Hmm but shouldn't we clean up on success too? I suppose the tmp dir will be cleaned up eventually, and maybe we want to keep them for debugging purposes.
    dacook committed Jul 9, 2024
    Configuration menu
    Copy the full SHA
    823614c View commit details
    Browse the repository at this point in the history
  3. Use Rails tmp dir for product imports again

    In openfoodfoundation#3435, it was switched to the system tmp dir because it conventiently provided a method to generate a unique filename. However it didn't handle the case where the system provided a symlink (macOS).
    
    I could have fixed that, but surely it's safer to use the Rails tmp directory.
    So I changed back to that, using a tip from https://stackoverflow.com/questions/13787746/creating-a-thread-safe-temporary-file-name to generate a unique name. Perhaps we could use a larger string (eg uuid) or append a timestamp too, but I don't know that it's necessary. Instead, we can just check that the dir didn't exist first (as mentioned in the PR). Let's do that..
    dacook committed Jul 9, 2024
    Configuration menu
    Copy the full SHA
    ca61228 View commit details
    Browse the repository at this point in the history
  4. Use system method to generate temporary file path

    This method is not documented, but is used by Dir.mktmpdir.  https://apidock.com/ruby/Dir/Tmpname/create
    dacook committed Jul 9, 2024
    Configuration menu
    Copy the full SHA
    2ab6bcb View commit details
    Browse the repository at this point in the history