[auth] Fix ~/.cache being deleted on linux (#4597)
## Description
Fixes https://github.com/ente-io/ente/issues/4536 and
https://github.com/ente-io/ente/issues/4464.
## Tests
After opening the app on linux, my 1.3G cache folder remained intact.
## Technical details
Now the path resolves to `~/.cache/io.ente.auth` instead of `~/.cache`.
[Under the
hood](ca4671cc0f/packages/path_provider/path_provider_linux/lib/src/path_provider_linux.dart (L75-L82))
it uses the app's ID and the `xdg_directories` package, so it will work
when the user has `XDG_CACHE_HOME` set to something else.
This commit is contained in:
@@ -24,16 +24,7 @@ class DirectoryUtils {
|
||||
}
|
||||
|
||||
static Future<Directory> getDirectoryForInit() async {
|
||||
Directory? directory;
|
||||
if (Platform.isLinux) {
|
||||
try {
|
||||
return cacheHome;
|
||||
} catch (e) {
|
||||
logger.warning("Failed to get cacheHome: $e");
|
||||
}
|
||||
}
|
||||
|
||||
directory ??= await getApplicationDocumentsDirectory();
|
||||
Directory directory = await getApplicationCacheDirectory();
|
||||
|
||||
return Directory(p.join(directory.path, "enteauthinit"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user