def update_metadata(metadata, new_metadata, now):
    """Updates 'metadata' in-place with the information in 'new_metadata'.

    Timestamps are set according to the time 'now'.
    """
    if metadata is None:
        metadata = {}
    old_ctime = None
    if 'ctime' in metadata:
        old_ctime = metadata['ctime']
    if new_metadata is not None:
        newmd = new_metadata.copy()
        if 'tahoe' in newmd:
            del newmd['tahoe']
        if 'tahoe' in metadata:
            newmd['tahoe'] = metadata['tahoe']
        metadata = newmd
    sysmd = metadata.get('tahoe', {})
    if 'linkcrtime' not in sysmd:
        if old_ctime is not None:
            sysmd['linkcrtime'] = old_ctime
        else:
            sysmd['linkcrtime'] = now
    sysmd['linkmotime'] = now
    metadata['tahoe'] = sysmd
    return metadata
