With elections this close, there is no telling what might happen. If the appeals takes a long time, he can run, be elected, then removed from presidency. Or he might run, but the appeals courts can finalize the decision after the cutoff for candidate applications. Or the appeals court might overturn, and things will go back to "normal".
We can only speculate till the courts makes its final decision.