Windows MTP device driver: Ignore failure to enumerate objects inside non-root folders

There are apparently a lot of devices out there that fail in this way.
So rather than aborting the scan simply ignore the folder.
This commit is contained in:
Kovid Goyal 2023-01-07 13:39:35 +05:30
parent 37fd1d521a
commit 7a829f484a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -320,6 +320,7 @@ find_objects_in(CComPtr<IPortableDeviceContent> &content, CComPtr<IPortableDevic
*/
CComPtr<IEnumPortableDeviceObjectIDs> children;
HRESULT hr = S_OK, hr2 = S_OK;
*enum_failed = false;
Py_BEGIN_ALLOW_THREADS;
hr = content->EnumObjects(0, parent_id, NULL, &children);
@ -338,7 +339,6 @@ find_objects_in(CComPtr<IPortableDeviceContent> &content, CComPtr<IPortableDevic
return false;
}
}
*enum_failed = false;
hr = S_OK;
@ -464,7 +464,11 @@ get_files_and_folders(unsigned int level, IPortableDevice *device, CComPtr<IPort
bool enum_failed = false;
if (!find_objects_in(content, object_ids, parent_id, &enum_failed)) {
return false;
// There are quite a few devices where EnumObjects fails for some folders, so unless it is the root folder ignore the failure.
if (!enum_failed || !level) return false;
PyErr_Print();
fwprintf(stderr, L"Ignoring failure of EnumObjects() at level %u\n", level); fflush(stderr);
return true;
}
if (bulk_properties != NULL) {