Skip to content

fix: users logged out after SDK upgrade due to different cache path #1168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 26, 2022
Next Next commit
Fixed app cache dir changes issue (#1158)
ParsePlugins ::
- `getCacheDir()`, `getFilesDir()` APIs now has support for backward compatibility before migration to v3.0.0
rommansabbir authored May 15, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 40ed19976c496bd32d6fa6cdda321942a437a19c
24 changes: 22 additions & 2 deletions parse/src/main/java/com/parse/ParsePlugins.java
Original file line number Diff line number Diff line change
@@ -178,7 +178,17 @@ InstallationId installationId() {
File getCacheDir() {
synchronized (lock) {
if (cacheDir == null) {
cacheDir = new File(applicationContext.getCacheDir(), "com.parse");
/*
Check for old reference file before migration to v3.0.0.
If old reference found, copy the ref to new directory and delete the ref.
*/
File oldRef = applicationContext.getDir("Parse", Context.MODE_PRIVATE);
if (oldRef.exists()) {
cacheDir = new File(oldRef, "com.parse");
oldRef.deleteOnExit();
} else {
cacheDir = new File(applicationContext.getCacheDir(), "com.parse");
}
}
return createFileDir(cacheDir);
}
@@ -187,7 +197,17 @@ File getCacheDir() {
File getFilesDir() {
synchronized (lock) {
if (filesDir == null) {
filesDir = new File(applicationContext.getFilesDir(), "com.parse");
/*
Check for old reference file before migration to v3.0.0.
If old reference found, copy the ref to new directory and delete the ref.
*/
File oldRef = applicationContext.getDir("Parse", Context.MODE_PRIVATE);
if (oldRef.exists()) {
filesDir = new File(oldRef, "com.parse");
oldRef.deleteOnExit();
} else {
filesDir = new File(applicationContext.getFilesDir(), "com.parse");
}
}
return createFileDir(filesDir);
}