copyPath:toPath:handler: more reliable than copyItemAtPath:toPath:error: ???
copyPath:toPath:handler: more reliable than copyItemAtPath:toPath:error: ???
- Subject: copyPath:toPath:handler: more reliable than copyItemAtPath:toPath:error: ???
- From: Laurent Daudelin <email@hidden>
- Date: Fri, 25 Mar 2011 12:08:53 -0700
I've been struggling with this for a few days and I can't find any resolution.
I've been trying to copy items from a local disk to an AFP-mounted volume with "copyItemAtPath:toPath:error:" and I found it to be unreliable in the sense that it will fail to set the modification date of the item copied to match that of the original item. It doesn't report any error, just silently continues.
However, if I use the (deprecated as of 10.5) "copyPath:toPath:handler:", this method will leave much less files with incorrect modification dates but will also return NO if it can't copy something properly. It will not, as with "copyItemAtPath:toPath:error:" send the handler the "fileManager:shouldProceedAfterError:" but at least, in some cases, it will return NO after the copy, so I can try to act on it.
The copies that end up with incorrect modification dates will vary from each run I do. I have found that, based on my experiment, you need to be copying at least 1000 items for the error to show. I'm assuming that if you have not a lot of items to copy, you are less likely to see the error. So, for now, I seem to be stuck using the older "copyPath:toPath:handler:" because "copyItemAtPath:toPath:error:" is unreliable at best. I also lose the ability to have an update for the actual items being copied specially if I'm copying a folder containing other folders and files.
This is happening with 2 different remote Macs. They are both running 10.5.8. One is an Intel iMac, the other a PowerPC Xserve. I have full permissions on both remote machines. I examined the original files and folders containing them for which the copies didn't have their modification dates set properly and didn't find anything different in the permissions than the other copies that had their modification dates set correctly. If that makes any difference, I'm running the copy method from an NSOperation but each copy is done sequentially. I thought about creating one NSOperation for each item to copy in a given folder but thought that was many not very wise.
Has anybody else noticed this?
-Laurent.
--
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/
Logiciels Nemesys Software email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden