message: truncate when offset == 0
diff: @@ -97,7 +97,7 @@ typedef struct GCSFile {
  static void SyncImpl(const std::string& bucket, const std::string& object,
  int64_t* offset, TempFile* outfile,
  gcs::Client* gcs_client, TF_Status* status) {
  - outfile->operator<<(std::flush);
  + outfile->flush();
  // `*offset == 0` means this file does not exist on the server.
  if (*offset == -1 || *offset == 0) {
  // UploadFile will automatically switch to resumable upload based on Client
  @@ -108,6 +108,11 @@ static void SyncImpl(const std::string& bucket, const std::string& object,
  return;
  }
  if (*offset == 0) {
  + if (!outfile->truncate()) {
  + TF_SetStatus(status, TF_INTERNAL,
  + "Could not truncate internal temporary file.");
  + return;
  + }
  *offset = static_cast<int64_t>(metadata->size());
  }
  outfile->clear();
  