mega.py icon indicating copy to clipboard operation
mega.py copied to clipboard

Could not a create folder on mega.py API

Open purshothamn opened this issue 5 years ago • 1 comments

image This is the error i'm getting. I try to reinstall mega,py but still the error is persistent.

purshothamn avatar Oct 21 '20 03:10 purshothamn

I don't know the heavy details here, but this error is thrown when file[1]['a'] is of string type instead of a dictionary. The following change to the find_path_descriptor method (see commented line below) appears to fix the issue.

def find_path_descriptor(self, path, files=()):
        """
        Find descriptor of folder inside a path. i.e.: folder1/folder2/folder3
        Params:
            path, string like folder1/folder2/folder3
        Return:
            Descriptor (str) of folder3 if exists, None otherwise
        """
        paths = path.split('/')

        files = files or self.get_files()
        parent_desc = self.root_id
        found = False
        for foldername in paths:
            if foldername != '':
                for file in files.items():
                    # if (file[1]['a'] and file[1]['t']
                    if (isinstance(file[1]['a'], dict) and file[1]['t']
                            and file[1]['a']['n'] == foldername):
                        if parent_desc == file[1]['p']:
                            parent_desc = file[0]
                            found = True
                if found:
                    found = False
                else:
                    return None
        return parent_desc

Achilles1515 avatar Mar 03 '21 05:03 Achilles1515