10 Replies Latest reply: Oct 28, 2014 2:55 AM by SteveBlatch Branched to a new discussion. RSS

    Errors when saving to SMB mounts (a thorough examination)

    Celery007 Community Member

      Several of the users I support have reported the following issue when trying to save files to the network from Photoshop. I have found several threads about this on both the Adobe forums and the Mac forums. However, in most of the threads the information provided is incomplete or does not control for enough variables. And the result is that Adobe seems to blame Apple, and Apple seems to blame Adobe. So blame aside, here is information that I hope helps Adobe solve the issue at hand.

       

      When saving to a mounted SMB point, users report one of two errors:

      • Could not save <filename> because of a program error
      • Could not save <filename> because write access was not granted

       

      I can replicate the issue on:

      1. Lion 10.7.X with Photoshop CS 5
      2. Lion 10.7.X with Photoshop CS 5.1
      3. Snow Leopard 10.6.X with Photoshop CS 5
      4. Snow Leopard 10.6.X with Photoshop CS 5.1

       

      Details:

      1. We have only seen this error in Photoshop.  << Adobe has seen the same problems in several other applications >>
      2. I have not tested out whether the issue applies to any other products in the CS suite.
      3. At first I thought the issue might have to do with permissions, but it does not. I have reapplied permissions and the issue persists. And it affects all users, including Domain Admins, such as me, who have no R/W restrictions at any level.
      4. The issue only occurs when Finder is in a view that shows a thumbnail/preview of the image.
      5. Switching Finder to list mode resolves the error in all scenarios
      6. So far I can replicate this with any file on any mount on any of our servers
      7. It only occurs on mounted network points (ie - if I move the files locally, no errors are encountered)

       

      For the following tests, presume the following:

      • Source folder: smb://example/source/folder
      • Target folder: smb://example/source/folder
      • Target sub-folder: smb://example/source/folder/sub

       

      Here are the steps I tested:

      1. Opened the file problem_file.psd.
      2. A warning pops up prompting me to resolve a font vector issue, I chose "Update"
        Note: that this error does not pop up for every file, just the original file I worked with, but this warning has nothing to do with the errors being received
      3. Moved a layer so that there would be a change to save
      4. Clicked save
      5. Received the error: "Could not save <filename> because of a program error"  << probably related to the known MacOS bug on SMB, or a known Finder/thumbnailing bug >>
      6. The original file, problem_file.psd, is *DELETED* (very problematic)  << Known MacOS bug in SMB service, Apple is working on it >>

       

      Then I tested with multiple variations of the following to conrol for things such as layers or font issues:

      • To eliminate the source file being the issue, I used a .png file that I had created locally with the OS-X screen shot keyboard command. This eliminated layers and fonts as issues.
      • In step 2 I chose to not update the font vector issue
      • In step 4 I tried saving as different file types (.jpg, .png, .gif)
      • Prior to step 6 I flattend the image to eliminate fonts and layers. This eliminated layers and fonts as issues.
      • Prior to step 6 I flattened the image, duplicate the image, closed the original (without saving), and attempted to save the new duplicate. This eliminated layers and fonts as issues.

       

      Each variation still resulted in "Could not save <filename> because of a program error" and resulted in the deletion of the source file.

       

      Next I controlled for saving image previews:

      1. Photoshop -> Preferences -> File Handling
      2. Under File Saving Options -> Image Previews, I set it to "Never Save" previews

       

      Now when I repeated the tests from aobve, I receved the error "Could not save <filename> because write access was not granted".

       

      Next I controlled for .DS_store files:

      1. Disabled .DS_Store file creation on remotely mounted points.
      2. Deleted the .DS_Store file for the source folder
      3. Verified that .ds_store files were not being created on remotely mounted points
      4. Ran the tests above, and the issue persisted: "Could not save <filename> because write access was not granted"

       

      Now I decided to test sub-folders:

      1. Created a target sub-folder.
      2. Repeated the test above, and its variations, but saving the problem_file.psd to the target sub-folder.
      3. Still received one of the two errors, depending on the variation, but the source file is no longer deleted. This make sense because saving in another directory is really a "save as", and one would not expect safe saving (talked about more later) to affect source files in this scenario.

       

      Sort of a Solution:

      1. Open the file from Finder
      2. Depending on the Finder view, Finder shows a thumnail of the image
      3. Go back to Finder and select a different file
      4. Make changes to the file
      5. Save the file
      6. No error is received

       

      This is when I discovered that the error only occurs when Finder is in a view that shows a thumbnail/preview of the image. Further testing of Finder show that in Cover Flow the error only occurs for the selected image. For example:

      1. Cover flow shows thumbnails/previews of files: A, B, C, D, E
      2. Open A
      3. In Cover Flow select file B
      4. The thumnails of of files A, B, C, D, E are still visible
      5. Make a change to the open file
      6. Save the change
      7. No error is received

       

      This shows that Finder is treating the thumbnails/previews of unselected files different than selected files.

       

      An Interesting Twist:

      If from the last scenario with Cover Flow...

      1. Open file A
      2. Go back to Finder and select a different file
      3. Then make a change and attempt to save to the target sub-folder
      4. Receive the error "Could not save <filename>" because of a program error.

       

      Discussion:

      Photoshop does something called safe saving.

      1. Photoshop saves the current document to a temporary file with a unique name
      2. Photoshop deletes the original file << this is incorrect >>
      3. Photoshop moves the temporary file to a file with the name of the original file that was deleted in step 2  << incorrect: the temp file replaces the original with an OS call to a function that is supposed to be an atomic operation >>

       

      However, you can see that "safe saving" is misnamed, because while the original is deleted, Photoshop does not appear to be correctly ensuring that permissions exist to allow the temporary file to be ranemd or that the temporary file was renamed without error. Photoshop is either:

      • Not checking for the error  << yes, it is >>
      • Checking for the permissions and not catching the error  << incorrect >>
      • Checking for the permissions and giving an error to generic to discern the exact problem from. << also incorrect >>

       

      Somewhere there is a conflict (perhaps a race condition) between:

      • Photoshop creating the temporary file
      • The server applying permission to the newly created temporary file
      • OS-X reporting the file has been created
      • Photoshop deleting the original file
      • Photoshop saving the new file
      • Finder updating the thumbnail of the file

       

      As I've shown here, the problem doesn't seem to reside fully with Apple or fully with Adobe. Hopefully this post provides enough information for some clever engineer to create a fix.

       

      My information about safe saving is from an Adobe mod on a previous thread regarding this issue << and copied incorrectly, plus added bad assumptions>>. He detailed the process and also explained that Photoshop uses OS APIs to create and delete the files during safe saving. If his details are accurate, it seems that a temporary fix would at least change the safe saving process to the following:

       

      1. Photoshop saves the current document to a temporary file with a unique name
      2. Photoshop moves the original file to a temporary backup file (original-file-name.original-extension.bak)
      3. Photoshop moves the temporary file to a file with the name of the original file moved in step 3
      4. Photoshop checks to make sure that the temporary file has been succesfully renamed
      5. If the temporary file has successfully been renamed, it deletes the backup file from step 2 OR if the temporary file has failed to be renamed, the backup is returned to its original file name
      6. The appropriate error message, if any, is displayed

       

      A Few Sources: