wabbajack-tools / wabbajack

An automated Modlist installer for various games.
https://www.wabbajack.org/
Other
745 stars 142 forks source link

Encountered error, can't continue - System.IO.IOException... #885

Closed ArgGrr closed 4 years ago

ArgGrr commented 4 years ago

When attempting to download and install a modpack for SkyrimVR, I get the following error and the process halts:

<snip>
6288.56 - Optimized 136961 directives to 136961 required
6288.58 - Hashing Archives
6288.59 - Looking for files to hash
6288.59 - Found 858 files to hash
6289.42 - Encountered error, can't continue - System.IO.IOException: (32) The process cannot access the file because it is being used by another process: [D:\MO2 VR Downloads\2.0.6.1\debug.log]
   at Alphaleonis.Win32.NativeError.ThrowException(UInt32 errorCode, String readPath, String writePath)
   at Alphaleonis.Win32.NativeError.ThrowException(Int32 errorCode, Nullable`1 isFolder, String readPath)
   at Alphaleonis.Win32.Filesystem.NativeMethods.CloseHandleAndPossiblyThrowException(SafeHandle handle, Int32 lastError, Nullable`1 isFolder, String path, Boolean throwException)
   at Alphaleonis.Win32.Filesystem.File.CreateFileCore(KernelTransaction transaction, Nullable`1 isFolder, String path, ExtendedFileAttributes attributes, FileSecurity fileSecurity, FileMode fileMode, FileSystemRights fileSystemRights, FileShare fileShare, Boolean checkPath, Boolean continueOnException, PathFormat pathFormat)
   at Alphaleonis.Win32.Filesystem.File.OpenCore(KernelTransaction transaction, String path, FileMode mode, FileSystemRights rights, FileShare share, ExtendedFileAttributes attributes, Nullable`1 bufferSize, FileSecurity security, PathFormat pathFormat)
   at Wabbajack.Common.Utils.FileHashAsync(AbsolutePath file, Boolean nullOnIOError) in C:\agent\_work\1\s\Wabbajack.Common\Hash.cs:line 237
   at Wabbajack.Common.Utils.FileHashCachedAsync(AbsolutePath file, Boolean nullOnIOError) in C:\agent\_work\1\s\Wabbajack.Common\Hash.cs:line 220
   at Wabbajack.Lib.AInstaller.<>c.<<HashArchives>b__50_5>d.MoveNext() in C:\agent\_work\1\s\Wabbajack.Lib\AInstaller.cs:line 305
--- End of stack trace from previous location where exception was thrown ---
   at Wabbajack.Common.Utils.<>c__DisplayClass99_1`2.<<PMap>b__1>d.MoveNext() in C:\agent\_work\1\s\Wabbajack.Common\Utils.cs:line 571
--- End of stack trace from previous location where exception was thrown ---
   at Wabbajack.Common.Utils.PMap[TI,TR](IEnumerable`1 coll, WorkQueue queue, Func`2 f) in C:\agent\_work\1\s\Wabbajack.Common\Utils.cs:line 588
   at Wabbajack.Lib.AInstaller.HashArchives() in C:\agent\_work\1\s\Wabbajack.Lib\AInstaller.cs:line 303
   at Wabbajack.Lib.MO2Installer._Begin(CancellationToken cancel) in C:\agent\_work\1\s\Wabbajack.Lib\MO2Installer.cs:line 113
   at Wabbajack.Lib.ABatchProcessor.<Begin>b__46_0() in C:\agent\_work\1\s\Wabbajack.Lib\ABatchProcessor.cs:line 164
   at Wabbajack.MO2InstallerVM.<>c__DisplayClass31_0.<<Install>b__0>d.MoveNext() in C:\agent\_work\1\s\Wabbajack\View Models\Installers\MO2InstallerVM.cs:line 165
--- End of stack trace from previous location where exception was thrown ---
   at Wabbajack.MO2InstallerVM.Install() in C:\agent\_work\1\s\Wabbajack\View Models\Installers\MO2InstallerVM.cs:line 159
   at Wabbajack.InstallerVM.<>c__DisplayClass92_0.<<-ctor>b__69>d.MoveNext() in C:\agent\_work\1\s\Wabbajack\View Models\Installers\InstallerVM.cs:line 364

I fixed it my patching paths.cs under WabbaJack.Common:

        public ValueTask<FileStream> OpenShared()
        {
            var path = _path;
            return CircuitBreaker.WithAutoRetry<FileStream, IOException>(async () =>
                File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
        }

Changing the file share mode to FileShare.ReadWrite seemed to do the trick. I think it is to do with files that are opened with write share, you can't open them with read share alone. I did this on 2.0.6.1, haven't tested 2.0.7.0 yet, still installing the modpack!

halgari commented 4 years ago

The circuit breaker code doesn't exist until 2.0.7.0, so that's probably what happened here. However, I think you're right, we do want ReadWrite here, so I'll put that in for the next version