'Fix the permissions for an imported Item or Album.'

def fix(self, lib, item=None, album=None):

    file_perm = config['permissions']['file'].get()
    dir_perm = config['permissions']['dir'].get()
    file_perm = convert_perm(file_perm)
    dir_perm = convert_perm(dir_perm)
    file_chmod_queue = []
    if item:
        file_chmod_queue.append(item.path)
    elif album:
        for album_item in album.items():
            file_chmod_queue.append(album_item.path)
    dir_chmod_queue = set()
    for path in file_chmod_queue:
        self._log.debug(u'setting    file    permissions    on    {}', util.displayable_path(path))
        os.chmod(util.syspath(path), file_perm)
        assert_permissions(path, file_perm, self._log)
        dir_chmod_queue.update(dirs_in_library(lib.directory, path))
    for path in dir_chmod_queue:
        self._log.debug(u'setting    directory    permissions    on    {}', util.displayable_path(path))
        os.chmod(util.syspath(path), dir_perm)
        assert_permissions(path, dir_perm, self._log)
