Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VirtualCodebase walk issue #57

Closed
JonoYang opened this issue Aug 24, 2023 · 1 comment
Closed

VirtualCodebase walk issue #57

JonoYang opened this issue Aug 24, 2023 · 1 comment
Assignees

Comments

@JonoYang
Copy link
Member

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.

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.

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

@JonoYang JonoYang self-assigned this Aug 24, 2023
JonoYang added a commit that referenced this issue Aug 24, 2023
Signed-off-by: Jono Yang <jyang@nexb.com>
JonoYang added a commit that referenced this issue Aug 25, 2023
  * If an existing resource is equa lto Codebase.CACHED_RESOURCE, then create that Resource

Signed-off-by: Jono Yang <jyang@nexb.com>
JonoYang added a commit that referenced this issue Aug 25, 2023
  * If an existing resource is equa lto Codebase.CACHED_RESOURCE, then create that Resource

Signed-off-by: Jono Yang <jyang@nexb.com>
@JonoYang
Copy link
Member Author

This fix has been merged into v31.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant