We have a huge amount of WAL files at backup site. A listing of the directory takes several seconds. During startup pg_receivewal checks size of all theus files. It does not check file integrity or gaps between files. It takes several hours for our setup.
I have add an options that skip this file size checking. Default behavior remains the same.
A patch looks huge due to large code block ident. Actually it consists of option add and one if-branch.