-
Notifications
You must be signed in to change notification settings - Fork 7
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
Bug: Multiple items with same name from different providers #448
Merged
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4895135
inital commit
15e786e
Flake-8
83e8f01
Fix Items from different providees
f18c14d
remove print
b21ce38
Create Layer variable and replace index with this
5a3e70a
Fix init bug
b2d7f4c
Merge conflicts
f5fac56
Remove index , it is outdated
9497a86
set layer
90c4257
set layer
4f3a33c
Remove dublicate code
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
|
||
L = logging.getLogger(__name__) | ||
|
||
|
||
# | ||
|
||
|
||
|
@@ -79,17 +80,14 @@ def __init__(self, app, service_name, paths=None): | |
self._create_library(path) | ||
app.PubSub.subscribe("Application.tick/60!", self.on_tick) | ||
|
||
|
||
async def finalize(self, app): | ||
while len(self.Libraries) > 0: | ||
lib = self.Libraries.pop(-1) | ||
await lib.finalize(self.App) | ||
|
||
|
||
async def on_tick(self, message_type): | ||
await self._read_disabled() | ||
|
||
|
||
def _create_library(self, path): | ||
library_provider = None | ||
if path.startswith('zk://') or path.startswith('zookeeeper://'): | ||
|
@@ -118,7 +116,6 @@ def _create_library(self, path): | |
|
||
self.Libraries.append(library_provider) | ||
|
||
|
||
def is_ready(self): | ||
""" | ||
It checks if all the libraries are ready. | ||
|
@@ -134,7 +131,6 @@ def is_ready(self): | |
True | ||
) | ||
|
||
|
||
async def _set_ready(self, provider): | ||
if len(self.Libraries) == 0: | ||
return | ||
|
@@ -149,8 +145,6 @@ async def _set_ready(self, provider): | |
L.log(LOG_NOTICE, "is NOT ready.", struct_data={'name': self.Name}) | ||
self.App.PubSub.publish("Library.not_ready!", self) | ||
|
||
|
||
|
||
async def read(self, path: str, tenant: str = None) -> typing.IO: | ||
""" | ||
Read the content of the library item specified by `path`. | ||
|
@@ -188,7 +182,6 @@ async def read(self, path: str, tenant: str = None) -> typing.IO: | |
|
||
return None | ||
|
||
|
||
async def list(self, path="/", tenant=None, recursive=False) -> list: | ||
""" | ||
List the directory of the library specified by the path. | ||
|
@@ -236,10 +229,9 @@ async def list(self, path="/", tenant=None, recursive=False) -> list: | |
child_items = await self._list(item.name, tenant, providers=item.providers) | ||
items.extend(child_items) | ||
recitems.extend(child_items) | ||
|
||
print(items) | ||
return items | ||
|
||
|
||
async def _list(self, path, tenant, providers): | ||
# Execute the list query in all providers in-parallel | ||
|
||
|
@@ -260,33 +252,28 @@ async def _list(self, path, tenant, providers): | |
continue | ||
|
||
for item in ress: | ||
|
||
item.disabled = self.check_disabled(item.name, tenant=tenant) | ||
|
||
# If the item already exists, merge it | ||
# If the item already exists, merge or override it | ||
pitem = uniq.get(item.name) | ||
if pitem is not None: | ||
pitem = uniq[item.name] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep |
||
if pitem.type == 'dir' and item.type == 'dir': | ||
# Directories are joined | ||
pitem.providers.extend(item.providers) | ||
|
||
elif pitem.type == 'item': | ||
for i, provider in enumerate(providers): | ||
if provider in item.providers: | ||
index = i | ||
break | ||
pitem.override = index | ||
# Other item types are skipped | ||
else: | ||
continue | ||
|
||
uniq[item.name] = item | ||
items.append(item) | ||
|
||
# Other item types are skipped | ||
else: | ||
uniq[item.name] = item | ||
items.append(item) | ||
items.sort(key=lambda x: x.name) | ||
return items | ||
|
||
|
||
async def _read_disabled(self): | ||
# `.disabled.yaml` is read from the first configured library | ||
# It is applied on all libraries in the configuration. | ||
|
@@ -305,7 +292,6 @@ async def _read_disabled(self): | |
self.Disabled = {} | ||
L.exception("Failed to parse '/.disabled.yaml'") | ||
|
||
|
||
def check_disabled(self, path, tenant=None): | ||
""" | ||
If the item is disabled for everybody, or if the item is disabled for the specified tenant, then | ||
|
@@ -330,7 +316,6 @@ def check_disabled(self, path, tenant=None): | |
|
||
return False | ||
|
||
|
||
async def export(self, path="/", tenant=None, remove_path=False) -> typing.IO: | ||
""" | ||
It takes a path, and returns a file-like object containing a gzipped tar archive of the library contents of | ||
|
@@ -385,7 +370,6 @@ async def export(self, path="/", tenant=None, remove_path=False) -> typing.IO: | |
fileobj.seek(0) | ||
return fileobj | ||
|
||
|
||
async def subscribe(self, paths): | ||
""" | ||
It subscribes to the changes in the library | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove print