Mark a zonefile as present (i.e. we stored it).
    Keep our in-RAM zonefile inventory coherent.
    Return the previous state.
    
    Returns True if the zone file was already present
    Returns False if it was not

def atlasdb_set_zonefile_present( zonefile_hash, present, con=None, path=None ):
    """
    Mark a zonefile as present (i.e. we stored it).
    Keep our in-RAM zonefile inventory coherent.
    Return the previous state.
    
    Returns True if the zone file was already present
    Returns False if it was not
    """
    global ZONEFILE_INV, ZONEFILE_INV_LOCK

    was_present = None
    with AtlasDBOpen(con=con, path=path) as dbcon:
        with ZONEFILE_INV_LOCK:
            # need to lock here in case someone tries to call atlasdb_cache_zonefile_info
            if present:
                present = 1
            else:
                present = 0

            sql = "UPDATE zonefiles SET present = ? WHERE zonefile_hash = ?;"
            args = (present, zonefile_hash)

            cur = dbcon.cursor()
            res = atlasdb_query_execute( cur, sql, args )
            dbcon.commit()
        
            zfbits = atlasdb_get_zonefile_bits( zonefile_hash, con=dbcon, path=path )
            
            inv_vec = None
            if ZONEFILE_INV is None:
                inv_vec = ""
            else:
                inv_vec = ZONEFILE_INV[:]

            # did we know about this?
            was_present = atlas_inventory_test_zonefile_bits( inv_vec, zfbits )

            # keep our inventory vector coherent.
            ZONEFILE_INV = atlas_inventory_flip_zonefile_bits( inv_vec, zfbits, present )
            log.debug('Set {} ({}) to {} (was_present={})'.format(zonefile_hash, ','.join(str(i) for i in zfbits), present, was_present))

    return was_present