stevejenkins / pihole-cloudsync

Syncs blocklists, blacklists, and whitelists across multiple Pi-holes using a private GitHub repo
MIT License
515 stars 105 forks source link

Fix bugs when importing from git repo #41

Open mgamlem3 opened 1 year ago

mgamlem3 commented 1 year ago

TL;DR:

DROP vs DELETE

This addresses issue #40. An explanation can be seen in this comment on the issue. Essentially, dropping the table is more destructive than what is needed when replacing the entries with the data from the csv files saved in git. Using the DELETE command preserves references, triggers, and other important information on the table.

Only modify if there is csv content

I was running into issues where the script would crash if there was no content in domainlist.csv and the script tried to import from it. Obviously, if there is no content in the file it doesn't need to be imported so I just added a check to see if there is anything in the file before attempting an import and modifying the table.

Ignore first line of csv when importing

The first line of the csv file should contain the column names from the SQL table. Skipping this line prevents errors and warnings when importing.

Add some semicolons

I was running into some strange issues with the if statements while making changes and adding these semicolons seemed to solve them.

stevejenkins commented 8 months ago

@mgamlem3 Can you take a peek and see what's conflicting with your merge request? I'm reactivating this project after a long pause. Thanks for your great help!

mgamlem3 commented 8 months ago

@stevejenkins it looked like some of the other changes you merged modified the same lines I did. I went ahead and resolved the conflicts while preserving my changes.

mgamlem3 commented 8 months ago

Also, this should close issue #40.