Skip to content

Commit 1166f02

Browse files
author
Jesse Bakker
committed
Use LOCALAPPDATA for system cache on windows
1 parent ceaa86f commit 1166f02

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lib/src/system_cache.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ 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%
3839
var appData = Platform.environment['APPDATA'];
39-
return p.join(appData, 'Pub', 'Cache');
40+
var appDataCacheDir = p.join(appData, 'Pub', 'Cache');
41+
if (Directory(appDataCacheDir).existsSync())
42+
return appDataCacheDir;
43+
var localAppData = Platform.environment['LOCALAPPDATA'];
44+
return p.join(localAppData, 'Pub', 'Cache');
4045
} else {
4146
return '${Platform.environment['HOME']}/.pub-cache';
4247
}

0 commit comments

Comments
 (0)