mercredi 10 décembre 2014

MAC: Icons only work on symbolic links when locked and are not updatable - need method for unlocking for non-privileged user


My client has a product based on Excel Spreadsheets which require periodic downloads. The product has been working well on PCs for several years, but there has been a lot of requests to have the product run on Macs as well. We have almost finished the porting process, but have run into an annoying problem when trying to put a link on the desktop to a file that can be deleted and recreated.


To work around the problem of 'hard' links we are using a symbolic link that is created during the installation process:


ln -s "/Applications/Mortgage Mentor/MortgageMentorUpdate.app" "/Users/$USER/Desktop/Mortgage Mentor Update"


We then put a 'nice' icon on it:


"/Applications/Mortgage Mentor/SetFileIcon" -image "/Applications/Mortgage Mentor/folder-icon.icns" -file "/Users/Shared/Mortgage Mentor"


The problem at this point is that the link does not show the Icon that has been assigned to it. This icon only appears when you Lock the file:


chflags uchg "/Users/$USER/Desktop/Mortgage Mentor"


Once this command is executed, we get a nice desktop icon. However, the link is now locked. If we run our network update program, which downloads and then replaces each of the files, including the main Mortgage Mentor.xlsm file, the symbolic link now points to the file in the trash, not in the original directory. So, our network update program tries to run a script to delete the symbolic link and recreate it - but that link is now locked and the script exits with an error and does not complete. So, we add a


sudo chflags nouchg "/Users/$USER/Desktop/Mortgage Mentor"


to the script, which also immediately breaks because there is no way for the script to talk to the user and request permission to run as it was launched as a sub-process by our update program.


2 things could be used to solve our problem: 1) Find a way to keep the symbolic link from following the file into the trash. We want it to ignore the deleted file and just point to the location where the replacement file is dropped. 2) find a way to turn off and then on again the Locked flag in the sub process without requiring super-user privileges, or even to do it within our program (using Mono).


My client does not want to have to prompt the user for special privileges to update files that they already own.


Any other suggestions would be welcome.


Thanks, Neil





Aucun commentaire:

Enregistrer un commentaire