From eebaa19178fcc7041f60aca762ea2ac9b128f23f Mon Sep 17 00:00:00 2001 From: 4sval Date: Fri, 6 Jan 2023 05:35:06 +0100 Subject: [PATCH] thread lock --- CUE4Parse | 2 +- FModel/ViewModels/CUE4ParseViewModel.cs | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CUE4Parse b/CUE4Parse index 7d4cd465..bfb2b3ce 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit 7d4cd4656e2ebf97caea2d010e20b033612e88ca +Subproject commit bfb2b3ce34ceee5c9785d845a5da2b594f534493 diff --git a/FModel/ViewModels/CUE4ParseViewModel.cs b/FModel/ViewModels/CUE4ParseViewModel.cs index 8a6c1056..7f5170e5 100644 --- a/FModel/ViewModels/CUE4ParseViewModel.cs +++ b/FModel/ViewModels/CUE4ParseViewModel.cs @@ -908,6 +908,7 @@ private void SaveExport(UObject export, bool auto) } } + private readonly object _rawData = new (); public void ExportData(string fullPath, bool updateUi = true) { var fileName = fullPath.SubstringAfterLast('/'); @@ -916,9 +917,12 @@ public void ExportData(string fullPath, bool updateUi = true) string path = UserSettings.Default.RawDataDirectory; Parallel.ForEach(assets, kvp => { - path = Path.Combine(path, UserSettings.Default.KeepDirectoryStructure ? kvp.Key : kvp.Key.SubstringAfterLast('/')).Replace('\\', '/'); - Directory.CreateDirectory(path.SubstringBeforeLast('/')); - File.WriteAllBytes(path, kvp.Value); + lock (_rawData) + { + path = Path.Combine(UserSettings.Default.RawDataDirectory, UserSettings.Default.KeepDirectoryStructure ? kvp.Key : kvp.Key.SubstringAfterLast('/')).Replace('\\', '/'); + Directory.CreateDirectory(path.SubstringBeforeLast('/')); + File.WriteAllBytes(path, kvp.Value); + } }); if (updateUi)