Alias folder causing nilObjectException

My app searches files and folders. It creates a list of folders to search in an array, but after upgrading to the latest Mac OSX on one computer, it created an alias folder called “Relocated items.nosync” in the Desktop folder. If that folder is there, it makes the search crash. If I take it out, it runs fine. I tried to exclude aliases with this, but it still crashes.

      if subFolderSearch.value = true then
    if f.directory then
      if f.alias = false and f <> nil then
        subFolderArrayZ.append f.absolutePath
      end if
    end if
  end if

Should you not be checking for f being nil before you check if f is a directory?

2 Likes

Open that folder and read the explanation inside the pdf file to understand what is that monkey business…

Apparently, the OS at one upgrade time created these folder(s).

Yes, I read it already. Here is what the text file inside says:

During the last macOS upgrade or file migration, some of your files couldn’t be moved to their new locations. This folder contains these files.

There is a Configuration folder within that folder also and it points to Users>Shared>Relocated Items>Configuration>Private>etc then there is a “group.system_default” file inside there.

I’d just like to know how to either prevent folder from being added to the array or to actually search it successfully. I believe it’s crashing at the point of being added to the array, but I’ll need to test a bit more to be sure.

Yes, I did check for nil first…

if myFile <> nil then
if myFile.Directory then

Your example code doesn’t show that though.

yeah i only included what i thought was more pertinent for brevity.

Test the extension (.nosync) before doing anything with the FolderItem ?

Yes, I thought of that but I also want to see if other aliases cause the same problem. Will need to make one and test it.

It appears that any alias causes it to crash, so testing for (.nosync) won’t help.

And it only does it on my Mac running Big Sur OS 11.4. My Mac running Mojave 10.14.6 seems to handle aliases okay. Wonder if they changed something???

I re-compiled my app in the latest version of XOJO and had to change absolutePath to nativePath in all cases and for some reason that seems to have fixed the issue. I was using an older version of XOJO previously.

1 Like

API 2.0 might be a dirty word, but the newer folderitem constructor allows for alias to be resolved while passing in a nativePath, or for my needs to NOT be resolved, which is nice IMHO.

There is a bug when using URLpaths, where it will always resolve an alias at urlPath regardless feedback://showreport?report_id=63416