SteamRE / DepotDownloader

Steam depot downloader utilizing the SteamKit2 library.
GNU General Public License v2.0
1.94k stars 262 forks source link

The process cannot access the file because it is being used by another process #532

Closed silentrald closed 1 month ago

silentrald commented 2 months ago

What did you expect to happen?

Game should be downloaded properly.

Instead of that, what actually happened?

DepotDownloader threw an error and could not download the game.

Which operating system are you running on?

Windows

Version

2.7.1

Command

DepotDownloader.exe -app 620980 -depot 620981 -dir "1.29.1" -manifest 886973241045584398 -qr

Relevant log output

Unhandled exception. System.IO.IOException: The process cannot access the file 'C:\Users\[username]\Downloads\DepotDownloader-windows-x64\1.29.1\Beat Saber_Data\CustomLevels\Jaroslav Beck - Beat Saber (Built in)\ExpertPlus.dat' because it is being used by another process.
   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.File.Open(String path, FileMode mode)
   at DepotDownloader.ContentDownloader.DownloadSteam3AsyncDepotFileChunk(CancellationTokenSource cts, GlobalDownloadCounter downloadCounter, DepotFilesData depotFilesData, FileData file, FileStreamData fileStreamData, ChunkData chunk) in D:\a\DepotDownloader\DepotDownloader\DepotDownloader\ContentDownloader.cs:line 1315
   at DepotDownloader.ContentDownloader.<>c__DisplayClass32_2.<<DownloadSteam3AsyncDepotFiles>b__5>d.MoveNext() in D:\a\DepotDownloader\DepotDownloader\DepotDownloader\ContentDownloader.cs:line 955
--- End of stack trace from previous location ---
   at DepotDownloader.Util.InvokeAsync(IEnumerable`1 taskFactories, Int32 maxDegreeOfParallelism) in D:\a\DepotDownloader\DepotDownloader\DepotDownloader\Util.cs:line 170
   at DepotDownloader.ContentDownloader.DownloadSteam3AsyncDepotFiles(CancellationTokenSource cts, GlobalDownloadCounter downloadCounter, DepotFilesData depotFilesData, HashSet`1 allFileNamesAllDepots) in D:\a\DepotDownloader\DepotDownloader\DepotDownloader\ContentDownloader.cs:line 953
   at DepotDownloader.ContentDownloader.DownloadSteam3Async(List`1 depots) in D:\a\DepotDownloader\DepotDownloader\DepotDownloader\ContentDownloader.cs:line 672
   at DepotDownloader.ContentDownloader.DownloadAppAsync(UInt32 appId, List`1 depotManifestIds, String branch, String os, String arch, String language, Boolean lv, Boolean isUgc) in D:\a\DepotDownloader\DepotDownloader\DepotDownloader\ContentDownloader.cs:line 535
   at DepotDownloader.Program.Main(String[] args) in D:\a\DepotDownloader\DepotDownloader\DepotDownloader\Program.cs:line 260
   at DepotDownloader.Program.<Main>(String[] args)

Additional Information

Might be similar to #188 but seems to be unrelated since this shows a different error log.

xPaw commented 2 months ago

Does it happen with other apps/depots? Does it happen every time?

silentrald commented 2 months ago

Does it happen with other apps/depots?

Only tested on the specific app and depot (Beat Saber 1.29.1)

Does it happen every time?

Yes, although the files aren't the same every time.

ie. in the logs I've posted, shows this file: [path]\1.29.1\Beat Saber_Data\CustomLevels\Jaroslav Beck - Beat Saber (Built in)\ExpertPlus.dat

and sometimes it can be: [path]\1.29.1\Beat Saber_Data\CustomLevels\Jaroslav Beck - Beat Saber (Built in)\NoArrowsExpert.dat

xPaw commented 2 months ago

Doesn't happen for me with the same command, and looking at the code there is a lock so same file should not open twice. Are you sure you don't have other software messing with it, like an antivirus?

silentrald commented 2 months ago

I'm helping out a friend on this so I'm not particular on his current setup. Will try to ask him about this. I'll try to keep you updated on this.

silentrald commented 1 month ago

Hi @xPaw, seems that there is an antivirus program (Avast). Although when I tested it in a virtual environment, DepotDownloader can still download the game files successfully.

I also suspect as well that there might be an application that might interfere with downloading files but that is out of scope of the DepotDownloader app. Will close the issue in any case.