Monday, November 13, 2023

How to correct file sizes in rehashed loose files torrent

This article is written for Cyberpunk 2077 update using loose file torrent rehash method but may be applied to any torrent.

If you rehash game files using updated torrent, download missing chunks and successfully recheck files in torrent client you may still get the error Cyberpunk 2077 encountered an error caused by corrupted or missing archives


This happens if some files were updated and their size became smaller in newer version of the game but torrent client did not truncate the file to reflect new smaller size. Even if the game data file contains all needed data and torrent rechecks OK Cyberpunk exe will check the size and will exit with the above error! 

You must use torrentcheck utility to find such files and manually delete and redownload them OR correct their sizes (semi)automatically using batch file TRUNCATE_REHASHED_TORRENT.BAT below. 

For this example in Cyberpunk 2077 update from 2.01 to 2.02 some files have become smaller.

How to correct file sizes in rehashed torrent:

  • Find them by running torrentcheck utility from the command line
    torrentcheck -t "{your_torrent_file}" -p "{your_game_path}" > errors.log
  • Check errors.log, you should see files that have mismatched size like this
    File .\Cyberpunk 2077 [Steam-Rip] by Ksenia\Cyberpunk 2077\archive\pc\ep1\ep1_2_gamedata.archive length mismatch, expected 12874928128 bytes, found 13124489216 bytes
  • Create TRUNCATE_REHASHED_TORRENT.BAT - copy and paste the code below
  • Run from command line
    TRUNCATE_REHASHED_TORRENT.BAT errors.log
  • Rerun torrentcheck and make sure that it detects no length mismatch errors.

 

TRUNCATE_REHASHED_TORRENT.BAT code:

@echo off
setlocal enabledelayedexpansion
for /f "delims=, tokens=1,2,*" %%A in ( '
    findstr "length mismatch" %1
' ) do (
   rem remove " length mismatch" at the end
   rem remove "File " at the beginning
   set filename=%%A
   set filename=!filename:~0,-16!
   set filename=!filename:~5!

   set filesize=%%B
   set filesize=!filesize:~0,-6!
   set filesize=!filesize:~10!

   fsutil file seteof "!filename!" !filesize!
)

2 comments:

  1. My torrentchecker.exe won't open, do you know how to fix it?

    ReplyDelete
  2. Hello, Muhammad! The utility is torrentcheck.exe. For example, if you downloaded your file.torrent into c:\temp folder, then downloaded the game using that torrent into c:\temp, put torrentcheck.exe into that same c:\temp folder. Run cmd.exe (Command Prompt) and type
    C:
    Cd \temp
    torrentcheck -t file.torrent -p . > errors.log
    When you use . as a folder name it means current folder

    ReplyDelete