Fix upload race condition