Repository navigation
cmd/syncthing: Do auto-upgrade before startup (fixes #6384) - #6385
Conversation
calmh
left a comment
There was a problem hiding this comment.
Looks OK to me. I want one more review on this by someone, as auto upgrade failures have a tendency to be really annoying to sort out after the fact...
|
I'll have a look in front of a larger screen |
| } | ||
| // Log the error if relevant. | ||
| if err != nil { | ||
| if _, ok := err.(errNoUpgrade); !ok { |
There was a problem hiding this comment.
Should this not be err.(*errNoUpgrade) ? As err is effectively an interface ( Error() string } hence it can't be a value, and is always a pointer?
Did you verify this works?
There was a problem hiding this comment.
I checked that it works. errNoUpgrade is returned, not a pointer. An interface variable need not be a pointer, it just has to implement the interface as a value or pointer. And usually methods are implemented with pointer receivers, but it is customary to use value receivers for custom errors (I guess because you never change them after creating).
There was a problem hiding this comment.
as I said, lgtm otherwise
AudriusButkevicius
left a comment
There was a problem hiding this comment.
lgtm other than that one question
* master: lib/db: Use need func in withNeed and simplify (syncthing#6412) cmd/syncthing: Do auto-upgrade before startup (fixes syncthing#6384) (syncthing#6385)
* master: lib/protocol: Zero pad index ID strings lib/db: Don't ignore failures unmarshaling version lists (syncthing#6411) lib/db: Use need func in withNeed and simplify (syncthing#6412) cmd/syncthing: Do auto-upgrade before startup (fixes syncthing#6384) (syncthing#6385) lib/db: Extend set test with second remote (syncthing#6402) gui, man, authors: Update docs, translations, and contributors lib/protocol: Use BlocksHash to compare block lists when available (syncthing#6401) lib/api: Ignore that one file that always shows up in git status
…g#6384) (syncthing#6385)" This reverts commit c101a04.
From #6384:
Of course it will never happen again that I produce a panic-inducing PR (ahem...), but nevertheless I believe that we definitely should do that.
I tested
-upgrade-check-upgradeand with and withoutSTNOUPGRADE=1: It all did the expected.I made
checkUpgradeExitOnErra function variable instead of a global function, as I believe no functions except themain...ones should ever callos.Exit. If it is considered ugly, I'd rather go for the little bit of duplication of explicitly handling the errors in the two upgrade ifs below that.