Fix opening of upstream file in some cases