Skip to content

Commit

Permalink
Update _get_parent_directory #57
Browse files Browse the repository at this point in the history
  * If an existing resource is equa lto Codebase.CACHED_RESOURCE, then create that Resource

Signed-off-by: Jono Yang <[email protected]>
  • Loading branch information
JonoYang committed Aug 25, 2023
1 parent 2e64acf commit 7c417a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/commoncode/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -2036,7 +2036,7 @@ def _get_parent_directory(self, path_segments):
for segment in path_segments:
path = posixpath_join(current.path, segment)
existing = resources_by_path.get(path)
if not existing:
if not existing or existing == Codebase.CACHED_RESOURCE:
existing = self._get_or_create_resource(
name=segment,
# build the path based on parent
Expand Down
14 changes: 2 additions & 12 deletions tests/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -1455,18 +1455,8 @@ def test_VirtualCodebase_can_be_created_with_repeated_root_directory(self):
paths = [
'to',
'to/to',
'to/to/com.liferay.portal.tika-1.0.22.jar',
'to/to/com.liferay.portal.tika-1.0.22.jar-extract',
'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22',
'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com',
'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay',
'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal',
'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika',
'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal',
'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/com/liferay/portal/tika/internal/activator',
'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/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/META-INF',
'to/to/com.liferay.portal.tika-1.0.22.jar-extract/com.liferay.portal.tika-1.0.22/META-INF/MANIFEST.MF',
'to/to/to',
'to/to/to/to',
]
resources = [{'path': path} for path in paths]
vc = VirtualCodebase(location={'files': resources})
Expand Down

0 comments on commit 7c417a8

Please sign in to comment.