Closed JonoYang closed 1 year ago
When I create a VirtualCodebase from the following data:
[{'is_file': False, 'path': 'to', 'sha1': '', 'size': 4096}, {'is_file': False, 'path': 'to/to', 'sha1': '', 'size': 4096}, {'is_file': True, 'path': 'to/to/com.liferay.portal.tika-1.0.22.jar', 'sha1': '07bfa85a425faacf3f1dcbda3ac13c9ff0a00f43', 'size': 10424}, {'is_file': False, 'path': 'to/to/com.liferay.portal.tika-1.0.22.jar-extract', 'sha1': '', 'size': 4096}, {'is_file': False, 'path': 'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22', 'sha1': '', 'size': 4096}, {'is_file': False, 'path': 'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com', 'sha1': '', 'size': 4096}, {'is_file': False, 'path': 'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay', 'sha1': '', 'size': 4096}, {'is_file': False, 'path': 'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal', 'sha1': '', 'size': 4096}, {'is_file': False, 'path': 'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika', 'sha1': '', 'size': 4096}, {'is_file': False, 'path': 'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal', 'sha1': '', 'size': 4096}, {'is_file': False, 'path': 'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal/activator', 'sha1': '', 'size': 4096}, {'is_file': True, 'path': 'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal/activator/TikaBundleActivator.class', 'sha1': '04bce1304882d0d1d1f851d4b0484bfd22df9956', 'size': 853}, {'is_file': False, 'path': 'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/META-INF', 'sha1': '', 'size': 4096}, {'is_file': True, 'path': 'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/META-INF/MANIFEST.MF', 'sha1': 'b259041906b9cc9db46a87ac5db538c8b2e59cce', 'size': 32212}]
I get into a strange loop when I try to use walk() on it.
walk()
to to/to to/com.liferay.portal.tika-1.0.22.jar-extract to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22 to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal/activator to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal/activator to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal/activator to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal/activator to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal/activator to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal/activator to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal/activator to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal/activator ...
We never end up visiting the resource 'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal/activator/TikaBundleActivator.class, and most of the paths start with to, instead of to/to.
'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal/activator/TikaBundleActivator.class
to
to/to
Looking into the problem, I see in commoncode.resource._get_parent_directory() that we are not properly appending the root path prefix when we are seeing if a path segment resource exists: https://github.com/nexB/commoncode/blob/main/src/commoncode/resource.py#L2037
commoncode.resource._get_parent_directory()
This fix has been merged into v31.0.3
When I create a VirtualCodebase from the following data:
I get into a strange loop when I try to use
walk()
on it.We never end up visiting the resource
'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal/activator/TikaBundleActivator.class
, and most of the paths start withto
, instead ofto/to
.Looking into the problem, I see in
commoncode.resource._get_parent_directory()
that we are not properly appending the root path prefix when we are seeing if a path segment resource exists: https://github.com/nexB/commoncode/blob/main/src/commoncode/resource.py#L2037