'Update the given folder\'s name or description.
:param  folder:        the model object
:type   folder:        LibraryFolder
:param  name:          new name for the library folder
:type   name:          str
:param  description:   new description for the library folder
:type   description:   str
:returns:   the folder
:rtype:     LibraryFolder
:raises: ItemAccessibilityException, InsufficientPermissionsException'

def update(self, trans, folder, name=None, description=None):

    changed = False
    if (not trans.user_is_admin()):
        if (not self.check_manageable(trans, folder)):
            raise InsufficientPermissionsException('You    do    not    have    proper    permission    to    update    the    library    folder.')
    if (folder.deleted is True):
        raise ItemAccessibilityException('You    cannot    update    a    deleted    library    folder.    Undelete    it    first.')
    if ((name is not None) and (name != folder.name)):
        folder.name = name
        changed = True
    if ((description is not None) and (description != folder.description)):
        folder.description = description
        changed = True
    if changed:
        trans.sa_session.add(folder)
        trans.sa_session.flush()
    return folder
