Skip to content

Commit f650df5

Browse files
committed
Explain why we fall back to %APPDATA% if it exists
1 parent e0f918a commit f650df5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

lib/src/system_cache.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ class SystemCache {
3535
if (Platform.environment.containsKey('PUB_CACHE')) {
3636
return Platform.environment['PUB_CACHE'];
3737
} else if (Platform.isWindows) {
38-
// If a cache dir already exists in %APPDATA%, use it, else default to %LOCALAPPDATA%
38+
// %LOCALAPPDATA% is preferred as the cache location over %APPDATA%, because the latter is synchronised between
39+
// devices when the user roams between them, whereas the former is not.
40+
// The default cache dir used to be in %APPDATA%, so to avoid breaking old installs,
41+
// we use the old dir in %APPDATA% if it exists. Else, we use the new default location
42+
// in %LOCALAPPDATA%.
3943
var appData = Platform.environment['APPDATA'];
4044
var appDataCacheDir = p.join(appData, 'Pub', 'Cache');
4145
if (dirExists(appDataCacheDir)) {

0 commit comments

Comments
 (0)