Photos 1.0: The AppleScript import command fails due to sandboxing
Originator: | andy.norman | ||
Number: | rdar://20583750 | Date Originated: | 04/17/2015 |
Status: | Closed | Resolved: | Behaves as intended |
Product: | OSX | Product Version: | 10.10.3 |
Classification: | Bug | Reproducible: | Always |
Summary: I am trying to import images into Photos.app using AppleScript. When I try and use the import command the images fail to import. When it fails the message in the UI is "Unreadable file", with the reason of "Unable to get metadata". There is also detail logged: 10/04/2015 22:40:02.994 Photos[18016]: Unable to get a thumbnail for 'PIC00001.JPG' (ERROR: Error Domain=PAImagingErrorDomain Code=200 "The operation couldn’t be completed. (PAImagingErrorDomain error 200.)" UserInfo=0x600001a7b040 {English Error String - Not Localized=CGImageSource is NULL for URL = 'file:///users/andy/20000408/PIC00001.JPG'}) 10/04/2015 22:44:24.560 sandboxd[16986]: ([18016]) Photos(18016) deny file-read-data /Users/andy/20000408/PIC00001.JPG This appears to be due to sandboxing in some way. I used codesign to re-sign a copy of Photos.app, so that it didn't have sandboxing. If I run that copy of Photos.app the import command works. Steps to Reproduce: 1. create an AppleScript that uses import: tell application "Photos" activate import {"/Users/andy/20000408/PIC00001.JPG"} end tell 2. run the AppleScript Expected Results: Image is imported Actual Results: Image fails to import and an error is given 10/04/2015 22:40:02.994 Photos[18016]: Unable to get a thumbnail for 'PIC00001.JPG' (ERROR: Error Domain=PAImagingErrorDomain Code=200 "The operation couldn’t be completed. (PAImagingErrorDomain error 200.)" UserInfo=0x600001a7b040 {English Error String - Not Localized=CGImageSource is NULL for URL = 'file:///users/andy/20000408/PIC00001.JPG'}) 10/04/2015 22:44:24.560 sandboxd[16986]: ([18016]) Photos(18016) deny file-read-data /Users/andy/20000408/PIC00001.JPG Version: 10.10.3 Notes: Configuration: Only tested on a single machine so far, MacBook Pro (13-inch, Early 2011) I don't have another machine with 10.10.3 to test it on.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Apple Developer Relations
This issue behaves as intended based on the following:
”POSIX path" is the standard way to point at a file when using AppleScript.
I ran into this same issue, but found a workaround.
Apparently, this fails if you pass the file path as a string. If you change the import line to pass a file object, it works:
That sure seems like a bug. If you pass a bogus string path, you get a different error, so Photos.app must somehow mishandle string paths (vs. file objects).