@Override
  public void close() throws IOException {
    if (myClosed) return;
    myClosed = true;

    if (myFailed) {
      abort();
      return;
    }

    @Nullable Path backup = waitForBackup();
    OutputStream sink = openFile();
    try {
      writeData(sink);
      deleteBackup(backup);
    }
    catch (IOException e) {
      restoreFromBackup(backup, e);
    }
  }
@Override
  public void close()