This project is archived and is in readonly mode.

#1702 ✓resolved
Tomas K.

atomic_write

Reported by Tomas K. | January 6th, 2009 @ 04:50 PM | in 2.x

When I use :file_store, Rails application must have permission to write in 'public/' directory. If it doesn't have access to 'public/', cache files are created as temporary files - i.e. 'menu.cache.20222.0' instead of 'menu.cache'.

atomic_write creates (in some cases) a file /permissions_check.XXXXXXX to determine the default permissions. This file is created in the current directory. If the script hasn't permission to write in the current directory, it fails and the code, which renames temporary file (created by the atomic_write) and changes its permissions, isn't executed.

The file .permission_check should be created in the same directory as the output file.

Note: It's my first report. If something is missing, let me know, I will add it.

Comments and changes to this ticket

  • joost baaij
  • Pratik

    Pratik March 8th, 2009 @ 03:18 PM

    • Assigned user set to “josh”
    • Tag changed from activesupport to activesupport, patch
  • josh

    josh March 10th, 2009 @ 02:48 AM

    • State changed from “new” to “resolved”

    Looks like this fix was already applied.

    
              begin
                # Get original file permissions
                old_stat = stat(file_name)
              rescue Errno::ENOENT
                # No old permissions, write a temp file to determine the defaults
                check_name = join(dirname(file_name), ".permissions_check.#{Thread.current.object_id}.#{Process.pid}.#{rand(1000000)}")
                open(check_name, "w") { }
                old_stat = stat(check_name)
                unlink(check_name)
              end
    

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages