GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4620
Also, use upstream library, as my changes have been merged.