mricon / ingress-fieldplan

Generate an easy workplan for Ingress fielding excursions
GNU General Public License v3.0
31 stars 8 forks source link

Code breaks when new solution has same name as previous one #26

Open sedaming opened 6 months ago

sedaming commented 6 months ago

I encountered an issue while using the Ingress Field Planner tool where the code breaks if a new solution has the same name as a previous one. This happens when the code tries to create a new sheet in Google Sheets with the same name as an existing one, which is not allowed.

Steps to reproduce:

  1. Run the code and get some results.
  2. Stop the code before it finishes all iterations.
  3. Run the code again.
  4. If the new solution has the same name as the previous one, the code will break with the following error message:
    googleapiclient.errors.HttpError: <HttpError 400 when requesting https://sheets.googleapis.com/v4/spreadsheets/[SPREADSHEET_ID]:batchUpdate?alt=json returned "Invalid requests[0].addSheet: A sheet with the name "[SHEET_NAME]" already exists. Please enter another name.". Details: "Invalid requests[0].addSheet: A sheet with the name "[SHEET_NAME]" already exists. Please enter another name.">

    Expected behavior:

The code should either overwrite the existing sheet with the new solution or append a unique identifier to the sheet name to avoid naming conflicts.

Suggested fix:

Before creating a new sheet, the code should check if a sheet with the same name already exists. If it does, the code could either: