Earlier quoted context omitted.
Willpower is a finite resource indeed, you can't rely on that.
Current research suggests that willpower is not a finite research and "ego depletion" was a spurious finding. https://www.psychologytoday.com/us/blog/how-do-you-know/2020...
Whatever you think of willpower, I think controlling the food environment (don't bring it home from the store, don't eat at restaurants with mainly junk food, etc) is the most effective intervention. After that, things like substitution, delay, smallest possible portion, and putting the tempting food in an inconvenient location may help.