I have an app that allows users to attach files to their document. I’ve been using Folderitem.Saveinfo and then saving this string with the document. This has worked just fine, even providing support for moved files in MacOS.
Lately I’ve been getting complaints from users that use this function to attach files on a LAN drive. If users are later off the LAN or the drive is not accessible then the user experiences a 30+ second timeout for each attached file while the OS tries to connect , followed by an OS based message - "There was a problem connecting to the server “xyz.” for each file. This makes the document essentially un-openable as the app is stuck in a 30-second-per-file spinning-wheel loop,
Questions -
How can I prevent this crippling time-out? Is there a way to detect that the volume is off-line without triggering the wheel-of-death?
Is there a way to save the file paths with my document that prevent this?
On OS X this behavior is the OS trying to resolve the alias
Its exactly as if you had an alias on your desktop to the document and double clicked it
I have this niggling feeling that there is some code laying in the forums (somewhere) that allows you to change the default behavior of OS X and how it resolves aliases but darned if I can find such a declare
Your problem is not how you save your file paths. It’s that once you get the path the server takes time to look for it.
I would put a boolean in your app that, when set to True, stops the attempt to open any additional files. That way you will have only the additional delay at least.
Thanks for the responses. I’ve been playing around with this some more and still can’t seem to find a good solution. While I can set as boolean as Roger suggested, it has the effect of stopping attempts for all files, not just the one on the unreachable server. Problem is since after a 30-second timeout, the returned folderitem is nil, so I can’t get to the root server name to mark it as offline. Interestingly, the OS message does reveal the offline server name. Is there a way for me to get the this name from the saveinfo data without attempting to retrieve the folderitem and trigger another 30-second hang? If not, I think this would be a good feature request.
how about when it fails for the first one… remember that “parent” portion of the path you just attempted.
if any other files have the same “parent”, then you know they will be unreachable, so do not even attempt
the return is NIL… but you know what you ATTEMPTED
Since I am using saveinfo, I don’t get back a folder item and I don’t have a path. Are you suggesting that I should also save the url path for the attachment, so I can parse that in case of trouble like this? I guess I can do that, though I thought that save info was supposed to be the preferred vehicle for storing file references. I worry that a mac file might be moved and thus may now have a different url.
[quote]Dim myPath As Folderitem = GetFolderItem(mySaveInfoStr, FolderItem.PathTypeNative)
dim theParent As Folderitem = myPath.parent[/quote]
I tried that. If the server is unavailable, the returned folderitem is nil. That being the case, I just need to mark the server name as unavaialble. But how do I learn the name of the server? And how do I compare it to other saveinfo strings to see if they are on the same server? That is my dilemma.
But you have the GetSaveInfo string. Right? That’s what you used to TRY to open the server location. That’s what Dave was telling you. Yes, you get nothing back from the server, but you know what you STARTED with.
I don’t want to do that. I’m starting to realize that I’m not going to be able to rely on the saveinfo string here. I’m considering getting the root folder name when the file is attached, then store that also. Makes me nervous because a) it is part of an absolute path and thus makes the reference less reliable. b) It introduces the possibility of name collisions. c) the root name I save may not even be the server that eventually becomes unavailable.
Hunt for posts by Thomas Templeman about aliases
I think he posted some code once about some mechanism to make it so you could test an alias etc to know
macOS CAN have several “paths” that all seems to be the same (you can have several mounted volumes with the same name but aliases to files on them would be different)
So when I parse a GSI string to get it’s folder item
Dim myPath As Folderitem = GetFolderItem(mySaveInfoStr, FolderItem.PathTypeNative)
displayText.Text = myPath.nativePath
Are you saying, Norman, that the path shown might not be the correct path?
I’m a bit confused.
That code requires being able to mount & resolve the file
If this cant be done you get nil so you have no server info & no file name
And its taken 30 seconds to figure this out
I’d need to look into this some more; and I don’t know if it’s even still supported, but you could try checking the volume info of a file and attaching that to your save data. Then when they try to re-open files, you check to see if that volume is connected.
The other option is to use the horrible macOS Security-Scoped Bodgemarks. In this situation they have a flag you can set when trying to access the bookmark that will stop the OS from trying to mount the volume. If it’s not connected, it fails instantly.
However I would not recommend SSBs otherwise; they’re horrible and if they fail (which they do for a variety of reasons) you can’t get any information out.
@Norman. I guess I misunderstood the use of GSI. I thought I could get a folder item from it whether or not a server mounted. Thanks for the clarification.