objectstore: add source method to api
Add a new jsoncomm rpc method call, `source`, that will return the directory within the store where resources for that specific type of resource, like e.g. tree, files, or ostree can be found or stored.
This commit is contained in:
parent
eb1d17d8ac
commit
aa9fee7b51
1 changed files with 22 additions and 1 deletions
|
|
@ -400,11 +400,21 @@ class StoreServer(api.BaseAPI):
|
|||
path = tempfile.mkdtemp(**args)
|
||||
sock.send({"path": path})
|
||||
|
||||
def _source(self, msg, sock):
|
||||
name = msg["name"]
|
||||
base = self.store.store
|
||||
path = os.path.join(base, "sources", name)
|
||||
sock.send({"path": path})
|
||||
|
||||
def _message(self, msg, _fds, sock):
|
||||
if msg["method"] == "read-tree":
|
||||
self._read_tree(msg, sock)
|
||||
if msg["method"] == "mkdtemp":
|
||||
elif msg["method"] == "mkdtemp":
|
||||
self._mkdtemp(msg, sock)
|
||||
elif msg["method"] == "source":
|
||||
self._source(msg, sock)
|
||||
else:
|
||||
raise ValueError("Invalid RPC call", msg)
|
||||
|
||||
|
||||
class StoreClient:
|
||||
|
|
@ -437,3 +447,14 @@ class StoreClient:
|
|||
msg, _, _ = self.client.recv()
|
||||
|
||||
return msg["path"]
|
||||
|
||||
def source(self, name: str) -> str:
|
||||
msg = {
|
||||
"method": "source",
|
||||
"name": name
|
||||
}
|
||||
|
||||
self.client.send(msg)
|
||||
msg, _, _ = self.client.recv()
|
||||
|
||||
return msg["path"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue