Skip to content

Commit f26a056

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

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
@@ -34,7 +34,11 @@ class SystemCache {
3434
if (Platform.environment.containsKey('PUB_CACHE')) {
3535
return Platform.environment['PUB_CACHE'];
3636
} else if (Platform.isWindows) {
37-
// If a cache dir already exists in %APPDATA%, use it, else default to %LOCALAPPDATA%
37+
// %LOCALAPPDATA% is preferred as the cache location over %APPDATA%, because the latter is synchronised between
38+
// devices when the user roams between them, whereas the former is not.
39+
// The default cache dir used to be in %APPDATA%, so to avoid breaking old installs,
40+
// we use the old dir in %APPDATA% if it exists. Else, we use the new default location
41+
// in %LOCALAPPDATA%.
3842
var appData = Platform.environment['APPDATA'];
3943
var appDataCacheDir = p.join(appData, 'Pub', 'Cache');
4044
if (io.dirExists(appDataCacheDir)) {

0 commit comments

Comments
 (0)