Update local metadata atomically using rename()

Change-Id: Id3b47db0d3ef3830f134d7f213e1d519d0466f60