UGreen NAS - Unable to enumerate contents of directory on iOS, works on macOS

I have a UGreen NAS. My app can read the contents of a folder on the NAS from macOS, but it cannot read the contents of a folder from iOS.

I bring up a UIDocumentPickerViewController(forOpeningContentTypes: [UTType.folder], asCopy: false).

I can pick a folder on the iPad’s internal storage, and successfully enumerate its contents. On the UGreen, I can pick a folder, but the content enumeration always returns zero items (no errors).

Enumeration of the UGreen works from macOS. It also works on the iPad when connecting to a Mac mini, or a Synology NAS. .

Files.app is able to view the UGreen folder and its contents. Oddly, my app cannot enumerate the contents, but it IS able to write a file to that UGreen folder.

Since Files.app can enumerate and I can write to the UGreen folder (and I can enumerate contents on other servers) - how can I get the enumeration to work? Feedback is FB22955130

Answered by DTS Engineer in 891953022

I can pick a folder on the iPad’s internal storage, and successfully enumerate its contents. On the UGreen, I can pick a folder, but the content enumeration always returns zero items (no errors).

So, based on what you've described, this sounds like a known (r.150542999) and fairly weird bug which I mentioned here.

In any case, the basic behavior was exactly what you've described (enumeration returns an empty directory), however, the odd part is that it ONLY did so on the first enumeration attempt. That is, enumerator(at:) returned an empty enumerator but if you then immediately tried again, it succeeded.

Note that I DON'T mean presenting the document picker again, I just mean directly retrieving the contents of the directory again. In terms of your code, doing something like this;

do {
	let contents = try fileManager.contentsOfDirectory(at: url, includingPropertiesForKeys: nil)
	let contents2 = try fileManager.contentsOfDirectory(at: url, includingPropertiesForKeys: nil)
	self.numberOfFilesLabel.text = "\(contents.count):\(contents2.count) items found"
}

Assuming it the issue above, then you'll get something like:

0:<#> items found

Please test with the retry above and let me know what you find.

Finally, it's still unclear what exactly is causing this issue. When I originally reproduced the issue in late iOS 18 it was specifically happening when macOS was presenting an external USB device over USB, but when I tested today I could not reproduce the issue. My guess is there is an underlying factor which ultimately triggers the issue, but at this point we haven't identified it.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

I'm assuming you are mounting the UGreen NAS using SMB?

Yes, it's mounted using SMB. The NAS supports either SMB2.x or SMB 3.

That's unexpected. The fact that Files.app can enumerate seems like that SMB is working fine against that NAS. The fact that UIDocumentPickerViewController() is working for you on macOS, but only fails on iOS and only against that particular server is very odd. I think we are going to need a bug report from you containing packet captures and iOS sysdiagnose when the problem occurs. Would be useful to have same packet captures and iOS sysdiagnose for a working situation so we can easily compare to see what's different.

How would I collect packet captures? I don't have experience with that. There is a feedback already in the system. FB22955130

I should mention that my customers are reporting the same thing with their UGreen, so it's not specific to my unit.

Found the bug report. If you can add a sysdiagnose for the "working" case (like on iOS, using your app against a server that is working), that should be good enough to start with. If we can't determine what is going wrong from the failing sysdiagnose vs working sysdiagnose, then we can give you instructions on how to get a packet trace later.

I just made one. But Feedback Assistant is down, so I will have to add it when it comes back up.

OK - I was able to upload three different sysdiagnoses:

  1. iPad -> Mac mini (works)
  2. Mac -> UGreen (works)
  3. iPad -> UGreen (doesn't work) - just to give an updated one

I can pick a folder on the iPad’s internal storage, and successfully enumerate its contents. On the UGreen, I can pick a folder, but the content enumeration always returns zero items (no errors).

So, based on what you've described, this sounds like a known (r.150542999) and fairly weird bug which I mentioned here.

In any case, the basic behavior was exactly what you've described (enumeration returns an empty directory), however, the odd part is that it ONLY did so on the first enumeration attempt. That is, enumerator(at:) returned an empty enumerator but if you then immediately tried again, it succeeded.

Note that I DON'T mean presenting the document picker again, I just mean directly retrieving the contents of the directory again. In terms of your code, doing something like this;

do {
	let contents = try fileManager.contentsOfDirectory(at: url, includingPropertiesForKeys: nil)
	let contents2 = try fileManager.contentsOfDirectory(at: url, includingPropertiesForKeys: nil)
	self.numberOfFilesLabel.text = "\(contents.count):\(contents2.count) items found"
}

Assuming it the issue above, then you'll get something like:

0:<#> items found

Please test with the retry above and let me know what you find.

Finally, it's still unclear what exactly is causing this issue. When I originally reproduced the issue in late iOS 18 it was specifically happening when macOS was presenting an external USB device over USB, but when I tested today I could not reproduce the issue. My guess is there is an underlying factor which ultimately triggers the issue, but at this point we haven't identified it.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

UGreen NAS - Unable to enumerate contents of directory on iOS, works on macOS
 
 
Q