All or nothing thinking

I use an app on my phone to tick off days that i don’t eat sugar or flour. I’ve been doing it for almost 2 years and when ive strung a week together it helps to motivate me to stick with the plan. But when I do eat something either by mistake like if a salad I order has a sweetened dressing or if i take a bite of something then I feel terribly disappointed and I’ll often decide I’ve blown it because I can’t count it as a successful day and then overeat. If i had many days strung together it sometimes takes me more than a day to get back on track.
So i know it’s my thoughts that cause these feelings and actions but I can’t seem to believe other thoughts. I wonder if I should stop trying to measure my days like this and try to rather just live with each decision in the moment.
Now that I’m writing this I also wonder if I’m relying too heavily on willpower and that’s why I need this extra motivation.
This worked for me when I was aiming for goal weight but now that I’m trying (and battling) to maintain my weight I’m having to rethink it.