Skip to content

Commit

Permalink
thread lock
Browse files Browse the repository at this point in the history
  • Loading branch information
4sval committed Jan 6, 2023
1 parent 41ebad4 commit eebaa19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions FModel/ViewModels/CUE4ParseViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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('/');
Expand All @@ -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)
Expand Down

0 comments on commit eebaa19

Please sign in to comment.