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

Use endpoint for cs3ref + use parent_id for relative paths in CS3Iface #67

Merged
merged 6 commits into from
Apr 6, 2022

Conversation

dragotin
Copy link
Contributor

@dragotin dragotin commented Mar 7, 2022

No description provided.

@dragotin dragotin requested a review from glpatcern as a code owner March 7, 2022 10:07
src/core/cs3iface.py Outdated Show resolved Hide resolved
src/core/cs3iface.py Outdated Show resolved Hide resolved
src/core/cs3iface.py Outdated Show resolved Hide resolved
@glpatcern glpatcern marked this pull request as draft March 8, 2022 10:37
@glpatcern
Copy link
Member

@dragotin and @wkloucek, shall we schedule some discussion to see how to proceed? I guess you're trying to support spaces, but the key point here is first to define how the /openinapp endpoint is (going to be) called from Reva within a space. Afterwards, we can see how to internally map the space id to an endpoint.

@glpatcern
Copy link
Member

glpatcern commented Mar 24, 2022

Update: following yesterday's "hackathon", this is feasible with some more extensions and after cs3org/cs3apis#167 is implemented in Reva. Shouldn't take much effort, we have already sketched the code for cs3iface.py yesterday.

@glpatcern glpatcern marked this pull request as ready for review March 24, 2022 09:40
@glpatcern glpatcern marked this pull request as draft March 24, 2022 11:36
@glpatcern glpatcern force-pushed the wipedge branch 2 times, most recently from 2577bb5 to a5de943 Compare March 25, 2022 16:57
@glpatcern glpatcern force-pushed the wipedge branch 2 times, most recently from ce05d30 to 4fa41e4 Compare March 28, 2022 08:39
This requires cs3org/cs3apis#167 and its
implementation in Reva in order to work
@labkode
Copy link
Member

labkode commented Mar 28, 2022

@glpatcern the parent_id is now merged upstream and cs3apis binding should be there for Python. Note that we require Reva-side implementation as well to return this value.

@glpatcern glpatcern marked this pull request as ready for review March 29, 2022 07:08
@wkloucek
Copy link
Contributor

@glpatcern please feel free to try cs3org/reva#2691. That should unblock the WOPI server on REVA edge.

@glpatcern glpatcern changed the title WIP: Use endpoint for cs3ref everywhere in CS3Iface Use endpoint for cs3ref + use parent_id for relative paths in CS3Iface Mar 29, 2022
@glpatcern
Copy link
Member

@glpatcern please feel free to try cs3org/reva#2691. That should unblock the WOPI server on REVA edge.

Thanks, looks good indeed but I won't have time to test it before Thursday I fear. Will do the equivalent code on Reva master for the eos provider - actually that PR could target Reva master and then get merged to Reva edge.

@glpatcern glpatcern self-requested a review March 29, 2022 09:34
@wkloucek
Copy link
Contributor

wkloucek commented Apr 4, 2022

I tried it today with the latest oCIS and needed to merge master into this branch and apply following patch to make it work:

diff --git a/src/core/cs3iface.py b/src/core/cs3iface.py
index c51de8c..962ca42 100644
--- a/src/core/cs3iface.py
+++ b/src/core/cs3iface.py
@@ -95,8 +95,7 @@ def stat(endpoint, fileref, userid, versioninv=1):
         inode = common.encodeinode(statInfo.info.id.storage_id, statInfo.info.id.opaque_id)
         # in case we got a relative path, build an hybrid path that can be used to reference the file:
         # note that as per specs the parent_id MUST be available in this case
-        filepath = statInfo.info.path if statInfo.info.path[0] == '/' else \
-                        statInfo.info.parent_id.opaque_id + '/' + os.path.basename(statInfo.info.path)
+        filepath = statInfo.info.parent_id.opaque_id + '/' + os.path.basename(statInfo.info.path)
         log.info('msg="Invoked stat" fileref="%s" inode="%s" filepath="%s" elapsedTimems="%.1f"' %
                  (fileref, inode, filepath, (tend-tstart)*1000))
         return {
@@ -257,7 +256,7 @@ def readfile(endpoint, filepath, userid, lockid):
 
     # Download
     try:
-        protocol = [p for p in initfiledownloadres.protocols if p.protocol == "simple"][0]
+        protocol = [p for p in initfiledownloadres.protocols if p.protocol == "simple" or p.protocol == "spaces"][0]
         headers = {
             'x-access-token': userid,
             'x-reva-transfer': protocol.token        # needed if the downloads pass through the data gateway in reva
@@ -304,7 +303,7 @@ def writefile(endpoint, filepath, userid, content, lockid, islock=False):
     # Upload
     try:
         # Get the endpoint for simple protocol
-        protocol = [p for p in initfileuploadres.protocols if p.protocol == "simple"][0]
+        protocol = [p for p in initfileuploadres.protocols if p.protocol == "simple" or p.protocol == "spaces"][0]
         headers = {
             'x-access-token': userid,
             'Upload-Length': size,

Also I had to ensure that external locks are disabled (detectexternallocks = False).

Then I could open files in edit mode, though I didn't succeed on saving files. This was most likely caused by the Set/GetXattr logic. From the logs I see that Set/GetXattr on REVA edge might be broken. Also I am not sure why a stat on current REVA edge returns a full path (it didn't the last time I checked)

@glpatcern
Copy link
Member

@wkloucek thanks for this, you can definitely push the patch on p.protocol == "spaces". Otherwise, the first patch won't be needed once Reva returns a relative path instead of a full path (yeah that does not sound correct), and the xattr logic must also work for save (PutFile) to work indeed.

@glpatcern glpatcern self-requested a review April 4, 2022 12:36
@glpatcern glpatcern merged commit eed2a45 into cs3org:master Apr 6, 2022
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

Successfully merging this pull request may close these issues.

4 participants