mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
37fd1d521a
commit
7a829f484a
@ -320,6 +320,7 @@ find_objects_in(CComPtr<IPortableDeviceContent> &content, CComPtr<IPortableDevic
|
|||||||
*/
|
*/
|
||||||
CComPtr<IEnumPortableDeviceObjectIDs> children;
|
CComPtr<IEnumPortableDeviceObjectIDs> children;
|
||||||
HRESULT hr = S_OK, hr2 = S_OK;
|
HRESULT hr = S_OK, hr2 = S_OK;
|
||||||
|
*enum_failed = false;
|
||||||
|
|
||||||
Py_BEGIN_ALLOW_THREADS;
|
Py_BEGIN_ALLOW_THREADS;
|
||||||
hr = content->EnumObjects(0, parent_id, NULL, &children);
|
hr = content->EnumObjects(0, parent_id, NULL, &children);
|
||||||
@ -338,7 +339,6 @@ find_objects_in(CComPtr<IPortableDeviceContent> &content, CComPtr<IPortableDevic
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*enum_failed = false;
|
|
||||||
|
|
||||||
hr = S_OK;
|
hr = S_OK;
|
||||||
|
|
||||||
@ -464,7 +464,11 @@ get_files_and_folders(unsigned int level, IPortableDevice *device, CComPtr<IPort
|
|||||||
|
|
||||||
bool enum_failed = false;
|
bool enum_failed = false;
|
||||||
if (!find_objects_in(content, object_ids, parent_id, &enum_failed)) {
|
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) {
|
if (bulk_properties != NULL) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user