Vscode repository mirror sync problem

When I try the sudo apt update command the following message is shown.

File has unexpected size (255716 != 256011). Mirror sync in progress? [IP: 52.163.211.218 80]
  Hashes of expected file:
   - Filesize:256011 [weak]
   - SHA512:9923e06a69f972b4fe12a9a01abeff42be235a49d91c2b5dc2d013e9aa495ccee7b468038aa98d2c57baaad89c55d1db8c2fe5b7825d8eabb90effc50e092a38
   - SHA256:66f52a872e8b4aecfacc20dbfec5b428973676a1cf188adcfbfa0e2572e9c620
   - SHA1:78871ddd4b7e6a6a37c49161cc5d94ec8189b276 [weak]
   - MD5Sum:b05f77c350a37dbe89ae6a21f6b8fa47 [weak]
  Release file created at: Thu, 26 Aug 2021 06:27:16 +0000
Fetched 332 kB in 1s (398 kB/s)
Reading package lists... Done
E: Failed to fetch http://packages.microsoft.com/repos/vscode/dists/stable/main/binary-amd64/Packages.bz2  File has unexpected size (255716 != 256011). Mirror sync in progress? [IP: 52.163.211.218 80]
   Hashes of expected file:
    - Filesize:256011 [weak]
    - SHA512:9923e06a69f972b4fe12a9a01abeff42be235a49d91c2b5dc2d013e9aa495ccee7b468038aa98d2c57baaad89c55d1db8c2fe5b7825d8eabb90effc50e092a38
    - SHA256:66f52a872e8b4aecfacc20dbfec5b428973676a1cf188adcfbfa0e2572e9c620
    - SHA1:78871ddd4b7e6a6a37c49161cc5d94ec8189b276 [weak]
    - MD5Sum:b05f77c350a37dbe89ae6a21f6b8fa47 [weak]
   Release file created at: Thu, 26 Aug 2021 06:27:16 +0000
E: Some index files failed to download. They have been ignored, or old ones used instead.

this has been the problem for over a week now. I'm not sure how to fix it or what the problem is. I'm on Ubuntu 20.04


Solution 1:

It means that the remote has been altered (likely the remote) since they made the checksum. You don't want that file. That is a check to defend against malware / spam / etc. and it is failing. Try uninstalling / reinstalling, or even installing the Snap. I didn't even know there was an Apt version of Code.

The commands would be

sudo apt uninstall <package-name>
sudo snap install code --classic`
sudo apt update

The whole purpose of the SHA, MD5, etc. is to insure that you are getting the same file that the developers are offering. That says that you are not. This could be a mistake on their part, but I wouldn't take any chances.

Also consider looking for / filing a bug report, or taking similar action.