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

v0.6 module crash on share_file_with_link #263

Open
luffah opened this issue Apr 15, 2021 · 1 comment
Open

v0.6 module crash on share_file_with_link #263

luffah opened this issue Apr 15, 2021 · 1 comment

Comments

@luffah
Copy link

luffah commented Apr 15, 2021

Hello,
<version pyocclient Version: 0.6 / pip / python3.6 >

i got crash with the following code :

    ...
    oc.put_file('testdir/remotefile.txt', 'localfile.txt')  # work ok
  
    link_info = oc.share_file_with_link('testdir/remotefile.txt')  # fails see below
  File "/usr/local/lib/python3.6/dist-packages/owncloud/owncloud.py", line 912, in share_file_with_link
    'name': data_el.find('name').text
AttributeError: 'NoneType' object has no attribute 'text'

When modifying the module, it works as expected (return the file sharing link):

--- /usr/local/lib/python3.6/dist-packages/owncloud/owncloud.py.orig	2021-04-15 17:30:51.306787700 +0200
+++ /usr/local/lib/python3.6/dist-packages/owncloud/owncloud.py	2021-04-15 17:31:14.850678321 +0200
@@ -901,13 +901,15 @@
             tree = ET.fromstring(res.content)
             self._check_ocs_status(tree)
             data_el = tree.find('data')
+            data_el_name = data_el.find('name')
             return ShareInfo(
                                 {
                                     'id': data_el.find('id').text,
                                     'path': path,
                                     'url': data_el.find('url').text,
                                     'token': data_el.find('token').text,
-                                    'name': data_el.find('name').text
+                                    'name': data_el_name.text if data_el_name
+                                    else ''
                                 }
             )
         raise HTTPResponseError(res)
@decentral1se
Copy link

Thanks for that fix @luffah! I had to drop back to 0.4 to get this to work.

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

2 participants