Skip to content

Commit 4f99a47

Browse files
committed
fix: Remove old ios file fallback
This change removes the fallback which would read from the very old location from dotnet days on ios. This means that any user who is still on the old maui version (over a year old) and updates, their data will not carry over. Their data is not deleted yet, so if there is a bug report we can bring it back. This old behaviour reading caused an issue where if we removed a value from the keyValueStore, it would not remove it from the old location, meaning when we read it again it would load extremely old data. This lead to an issue with loading the current session state on ios apps which have transitioned from the old app to the new. Basically the old version of the app which was essentially a web app (maui+blazor) used to write files in a different location to where the new react native app does, but only on ios. I added a compatibility layer where it would read those old files but not write them. Recently when I changed the format from proto to json, what would happen is from file CURRENT_SESISON_VERSION LiftLog would read the what type of file it is (proto or JSON). Then from CURRENT_SESSION it would read the actual current session file. Now unfortately in ios it would actually read CURRENT_SESSION which would say it is the new format, but when it would read CURRENT_SESSION, that file is not there (as there is no current session, it is complete), but then it would fallback to CURRENT_SESSION_OLD_LOCATION where there WAS a file there from the maui version of liftlog. It tries to read the proto file as json and explodes. I think it's been long enough, we don't need that fallback. fixes: #860
1 parent 883bd96 commit 4f99a47

1 file changed

Lines changed: 0 additions & 25 deletions

File tree

app/src/services/key-value-store.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
import { uuid } from '@/utils/uuid';
22
import { File, Paths } from 'expo-file-system';
3-
import { Platform } from 'react-native';
4-
import { getLibraryDirectory } from '~/modules/native-lib';
53

64
export class KeyValueStore {
75
async getItem(key: string): Promise<string | undefined> {
86
const file = getFile(key);
97
if (file.exists) {
108
return file.text();
119
}
12-
const oldFile = getOldDirFile(key);
13-
if (oldFile?.exists) {
14-
return oldFile.text();
15-
}
1610
return undefined;
1711
}
1812

@@ -21,10 +15,6 @@ export class KeyValueStore {
2115
if (file.exists) {
2216
return this.readBytes(file);
2317
}
24-
const oldFile = getOldDirFile(key);
25-
if (oldFile?.exists) {
26-
return this.readBytes(oldFile);
27-
}
2818
return undefined;
2919
}
3020

@@ -62,10 +52,6 @@ export class KeyValueStore {
6252
if (file.exists) {
6353
return file.textSync();
6454
}
65-
const oldFile = getOldDirFile(key);
66-
if (oldFile?.exists) {
67-
return oldFile.textSync();
68-
}
6955
return undefined;
7056
}
7157

@@ -89,17 +75,6 @@ export class KeyValueStore {
8975
}
9076
}
9177

92-
function getOldDirFile(key: string): File | undefined {
93-
// For iOS, the Library/Application Support directory (equivalent to .NET MAUI's FileSystem.AppDataDirectory)
94-
// We want to only read from this, and store in the appropriate documents dir
95-
if (Platform.OS === 'ios' || Platform.OS === 'macos') {
96-
const libraryDir = getLibraryDirectory();
97-
return new File(Paths.join(libraryDir, key));
98-
} else {
99-
return undefined;
100-
}
101-
}
102-
10378
function getFile(key: string): File {
10479
return new File(Paths.join(Paths.document, key));
10580
}

0 commit comments

Comments
 (0)