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

Error while using makedirs from PyFilesystem #10

Closed
blasterspike opened this issue Aug 11, 2018 · 1 comment · Fixed by #11
Closed

Error while using makedirs from PyFilesystem #10

blasterspike opened this issue Aug 11, 2018 · 1 comment · Fixed by #11

Comments

@blasterspike
Copy link
Contributor

Hi,
I'm getting an error while trying to use makedirs from PyFilesystem with pycloud.
As per documentation from PyFilesystem
https://docs.pyfilesystem.org/en/latest/reference/base.html#fs.base.FS.makedirs

Make a directory, and any missing intermediate directories.

Using this code

import fs
from pcloud import PyCloud
import urllib.parse

username = urllib.parse.quote_plus('my_username')
password = urllib.parse.quote_plus('my_password')

with fs.opener.open_fs('pcloud://{0}:{1}@/'.format(username, password)) as pcloud_fs:
    pcloud_fs.makedirs(path='/backup/second_level/third_level', recreate=True)

I'm getting the following error

Traceback (most recent call last):
  File "fs_makedirs.py", line 10, in <module>
    pcloud_fs.makedirs(path='/backup/second_level/third_level', recreate=True)
  File "/usr/local/lib/python3.6/site-packages/fs/base.py", line 1035, in makedirs
    dir_paths = tools.get_intermediate_dirs(self, path)
  File "/usr/local/lib/python3.6/site-packages/fs/tools.py", line 82, in get_intermediate_dirs
    resource = fs.getinfo(path)
  File "/usr/local/lib/python3.6/site-packages/pcloud/pcloudfs.py", line 118, in getinfo
    for item in folder_list['metadata']['contents']:
KeyError: 'metadata'

where:
/backup: it exists
/backup/second_level: it doesn't exist
/backup/third_level: it doesn't exist

and getinfo tries to fetch metadata of a directory that doesn't exist (parent_path = /backup/second_level).

Versions used in this test:
macOS 10.11.6
Python 3.6.5
fs==2.0.27
pcloud==1.0a4

Regards

Massimo

@tomgross
Copy link
Owner

Fixed with #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants