I have a RAID disk which makes its files available over CIFS/SMB. If I copy a large file (600MB) from one location on the volume to another location on the same volume using Finder (i.e., option-drag the file), it only takes a second or two.
If I try to do the same operation programmatically using the code below, it takes upwards of a minute.
let source = URL(filePath: "/Volumes/media/tmp/bigfile.dat")
let dest = URL(filePath: "/Volumes/media/finaldest/file.dat")
try FileManager.default.copyItem(at: source, to: dest)
My theory is that Finder can detect that the source and destination are on the same network volume and uses a special SMB API to do the copying server side, without having to move a bunch of bytes back and forth over the network. FileManager does not have this same optimization.
Does anybody have suggestions on how I can make my program behave like the Finder does?