Skip to content

Commit e3abf5a

Browse files
DYN-9958 WebView2 Cache Folder (#16824)
(cherry picked from commit 6d13465)
1 parent 2996356 commit e3abf5a

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

src/DynamoCoreWpf/Utilities/WebView2Utilities.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
using System;
2+
using System.Diagnostics;
3+
using System.IO;
24
using System.Threading;
35
using System.Threading.Tasks;
46
using System.Windows;
7+
using Dynamo.Configuration;
58
using Dynamo.Models;
69
using Dynamo.Wpf.Properties;
710
using DynamoUtilities;
@@ -103,5 +106,21 @@ public static bool ValidateWebView2RuntimeInstalled()
103106
return false;
104107
}
105108
}
109+
110+
/// <summary>
111+
/// Returns the user data folder path for WebView2 (used in SplashScreen, HomePage, PackageManagerWizard)
112+
/// </summary>
113+
/// <returns>user data folder path for WebView2</returns>
114+
internal static string GetTempDirectory()
115+
{
116+
// Create a temp folder unique to this Dynamo instance based on process id
117+
string localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
118+
string tmpDataFolder = Path.Combine(
119+
localAppData,
120+
"Temp",
121+
Configurations.DynamoAsString,
122+
"WebView2");
123+
return tmpDataFolder;
124+
}
106125
}
107126
}

src/DynamoCoreWpf/Views/HomePage/HomePage.xaml.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,7 @@ private void DynamoViewModel_PropertyChanged(object sender, System.ComponentMode
137137
/// <returns></returns>
138138
private static string GetUserDirectory()
139139
{
140-
var version = AssemblyHelper.GetDynamoVersion();
141-
142-
var folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
143-
return Path.Combine(Path.Combine(folder, "Dynamo", "Dynamo Core"),
144-
String.Format("{0}.{1}", version.Major, version.Minor));
140+
return WebView2Utilities.GetTempDirectory();
145141
}
146142

147143
private async void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e)

src/DynamoCoreWpf/Views/PackageManager/Components/PackageManagerWizard/PackageManagerWizard.xaml.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,11 +1007,7 @@ internal bool ProcessUri(string uri)
10071007
/// <returns></returns>
10081008
private static string GetUserDirectory()
10091009
{
1010-
var version = AssemblyHelper.GetDynamoVersion();
1011-
1012-
var folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
1013-
return Path.Combine(Path.Combine(folder, "Dynamo", "Dynamo Core"),
1014-
String.Format("{0}.{1}", version.Major, version.Minor));
1010+
return WebView2Utilities.GetTempDirectory();
10151011
}
10161012

10171013
/// <summary>

src/DynamoCoreWpf/Views/SplashScreen/SplashScreen.xaml.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,7 @@ private void DynamoModel_RequestUpdateLoadBarStatus(SplashScreenLoadEventArgs ar
342342
/// <returns></returns>
343343
private string GetUserDirectory()
344344
{
345-
var version = AssemblyHelper.GetDynamoVersion();
346-
347-
var folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
348-
return Path.Combine(Path.Combine(folder, Configurations.DynamoAsString, "Dynamo Core"),
349-
String.Format("{0}.{1}", version.Major, version.Minor));
345+
return WebView2Utilities.GetTempDirectory();
350346
}
351347

352348
protected override async void OnContentRendered(EventArgs e)

0 commit comments

Comments
 (0)