'Because the Galaxy Data Libraries API/system does not act like any
other file system in existence, and allows multiple files/folders with
identical names in the same parent directory, we have to prepopulate
the memoization cache with everything currently in the target
directory.
Because the Galaxy Data Libraries API does not work from a perspective
of "show me what is in this directory", we are forced to get the entire
contents of the data library, and then filter out things that are
interesting to us based on a folder prefix.'

def prepopulate_memo(self):

    existing = self.gi.libraries.show_library(self.library_id, contents=True)
    uploading_to = [x for x in existing if (x['id'] == self.folder_id)]
    if (len(uploading_to) == 0):
        raise Exception(('Unknown    folder    [%s]    in    library    [%s]' % (self.folder_id, self.library_id)))
    else:
        uploading_to = uploading_to[0]
    for x in existing:
        if (not x['name'].startswith(uploading_to['name'])):
            continue
        name_part = x['name'].split(uploading_to['name'], 1)[(-1)]
        if name_part.startswith('/'):
            name_part = name_part[1:]
        self.memo_path[name_part] = x['id']
