emanzione / PATCH

The PATCH repository for issues tracking, wiki and shared material.
https://assetstore.unity.com/packages/tools/utilities/p-a-t-c-h-ultimate-patching-system-41417
MIT License
47 stars 7 forks source link

[Bug] System.IO.DirectoryNotFoundException on UpdatingContext.Initialize() call #52

Closed DmitriyYukhanov closed 2 years ago

DmitriyYukhanov commented 2 years ago

Looks like there is a tiny bug which causes the System.IO.DirectoryNotFoundException after context.Initialize() call when having same non-existing folder path set to AppDataPath and RootPath.

What I'm trying to do: download the game from standalone launcher to the specified folder. What I expected to see: non-existing folder gets created when necessary & CleanWorkspace method shouldn't execute file removal at all if target folder doesn't exist.

Here is a stack trace:

System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\focus\AppData\Roaming\Project\Game'.
   at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
   at System.IO.Enumeration.FileSystemEnumerator`1.Init()
   at System.IO.Enumeration.FileSystemEnumerator`1..ctor(String directory, Boolean isNormalized, EnumerationOptions options)
   at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options, Boolean isNormalized)
   at System.IO.Enumeration.FileSystemEnumerableFactory.UserFiles(String directory, String expression, EnumerationOptions options)
   at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
   at System.IO.Directory.GetFiles(String path, String searchPattern, EnumerationOptions enumerationOptions)
   at System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption)
   at MHLab.Patch.Core.IO.FilesManager.GetFiles(String path, String pattern)
   at MHLab.Patch.Core.IO.FilesManager.DeleteMultiple(String directory, String pattern)
   at MHLab.Patch.Core.IO.FileSystem.DeleteMultipleFiles(FilePath path, String pattern)
   at MHLab.Patch.Core.Client.UpdatingContext.CleanWorkspace()
   at MHLab.Patch.Core.Client.UpdatingContext.Initialize()
emanzione commented 2 years ago

Prevented this exception by checking the path in FilesManager.DeleteMultiple. It should be enough to mitigate the issue! It will be included in the next version release!

Commit ref: 53a0bc0b