File tree Expand file tree Collapse file tree 3 files changed +57
-0
lines changed
Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,31 @@ struct SushitrainApp: App {
4444 Log . info ( " Logging enabled: \( enableLogging) " )
4545
4646 let client = SushitrainNewClient ( configPath, documentsPath, enableLogging) !
47+
48+ // Optionally clear v1 and/or v2 index
49+ let clearV1Index = UserDefaults . standard. bool ( forKey: " clearV1Index " )
50+ let clearV2Index = UserDefaults . standard. bool ( forKey: " clearV2Index " )
51+ if clearV1Index {
52+ Log . info ( " Deleting v1 index... " )
53+ do {
54+ try client. clearV1Index ( )
55+ UserDefaults . standard. setValue ( false , forKey: " clearV1Index " )
56+ }
57+ catch {
58+ Log . warn ( " Failed to delete v1 index: " + error. localizedDescription)
59+ }
60+ }
61+ if clearV2Index {
62+ Log . info ( " Deleting v2 index... " )
63+ do {
64+ try client. clearV2Index ( )
65+ UserDefaults . standard. setValue ( false , forKey: " clearV2Index " )
66+ }
67+ catch {
68+ Log . warn ( " Failed to delete v2 index: " + error. localizedDescription)
69+ }
70+ }
71+
4772 let appState = AppState ( client: client, documentsDirectory: documentsDirectory, configDirectory: configDirectory)
4873 self . appState = appState
4974
Original file line number Diff line number Diff line change 2222 <key >DefaultValue </key >
2323 <false />
2424 </dict >
25+ <dict >
26+ <key >Type </key >
27+ <string >PSToggleSwitchSpecifier </string >
28+ <key >Title </key >
29+ <string >Delete v1 index </string >
30+ <key >Key </key >
31+ <string >clearV1Index </string >
32+ <key >DefaultValue </key >
33+ <false />
34+ </dict >
35+ <dict >
36+ <key >Type </key >
37+ <string >PSToggleSwitchSpecifier </string >
38+ <key >Title </key >
39+ <string >Delete v2 index </string >
40+ <key >Key </key >
41+ <string >clearV2Index </string >
42+ <key >DefaultValue </key >
43+ <false />
44+ </dict >
2545 </array >
2646</dict >
2747</plist >
Original file line number Diff line number Diff line change @@ -1338,3 +1338,15 @@ func ShortDeviceID(devID string) string {
13381338 }
13391339 return did .Short ().String ()
13401340}
1341+
1342+ func (c * Client ) ClearV1Index () error {
1343+ dbPath := locations .Get (locations .LegacyDatabase )
1344+ Logger .Warnf ("Removing v1 index at %s" , dbPath )
1345+ return os .RemoveAll (dbPath )
1346+ }
1347+
1348+ func (c * Client ) ClearV2Index () error {
1349+ dbPath := locations .Get (locations .Database )
1350+ Logger .Warnf ("Removing v2 index at %s" , dbPath )
1351+ return os .RemoveAll (dbPath )
1352+ }
You can’t perform that action at this time.
0 commit comments