mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
SQLite data lost when killing the app #385
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @odilebellerose on GitHub (Mar 30, 2022).
Hi,
when i create some objects by using
, everything is working well i can see datas in my sqlite database. However, when i kill my app, the database is empty.
I've tried to save context on applicationWillTerminate but it doesn't change anything,
Any idea of what's happens ?
Thanks you in advance for your answer.
@JohnEstropia commented on GitHub (Mar 30, 2022):
I'm not sure I understand what you mean. You are sure that the SQLite database is created and populated correctly, but the file disappears after you terminate the app?
If so then something in your code is deleting the database manually, as CoreStore doesn't have any mechanism that automatically deletes the store.
@odilebellerose commented on GitHub (Mar 30, 2022):
The database still exists but records are deleted. Do you know if there is a way that CoreStore re-create sqlite database or erase the content ?
@JohnEstropia commented on GitHub (Mar 30, 2022):
Is the SQLite file URL constant or is it generated and somehow changes every launch?
The only reason CoreStore would reset a database is if the schema was updated AND the
.recreateStoreOnModelMismatchoption is set on theSQLiteStore@odilebellerose commented on GitHub (Mar 30, 2022):
I have a Singleton, with a start() func :
and i'm calling this function in the AppDelegate :
@JohnEstropia commented on GitHub (Mar 30, 2022):
Are you using storyboards? If so you are likely accessing the
DataStackbeforeaddStorageAndWait()returns. Storyboard initial ViewControllers get initialized before theUIAppDelegate'sdidFinishLaunchingis called. At least if I recall correctly.Put a breakpoint on the
dataStackgetter and theaddStorageAndWait()call and see if it's getting accessed somewhere else before the store is added.@odilebellerose commented on GitHub (Mar 30, 2022):
I'm not using Storyboards and i tried to put breakpoints on functions using the dataStack it's seems ok. The
addStorageAndWait()func seems to be called first.@JohnEstropia commented on GitHub (Mar 30, 2022):
How are you confirming the SQLite file contents? Are you sure the
perform()methods are completing successfully?@odilebellerose commented on GitHub (Mar 30, 2022):
If i open the SQLite file in a browser i can see my records. In fact, i'm using CoreStore to store documents that i'm going to upload by using operation queue and background task. If i keep the app open or put it in the background, everything is working well. That's why i can confirm SQLite file contents. If i kill the app and re-open it, my app should fetch documents in database and try to re-upload documents but they have been deleted.
@JohnEstropia commented on GitHub (Mar 30, 2022):
After restarting the app, do you still see the records in the SQLite browser?
@odilebellerose commented on GitHub (Mar 30, 2022):
No, i can't.
@JohnEstropia commented on GitHub (Mar 30, 2022):
There's definitely something deleting your file (or a parent folder) somewhere. If you can isolate the issue in a shareable project I'll try to take a look.
@odilebellerose commented on GitHub (Mar 30, 2022):
Unfortunately i can't :/
Thanks you for your help, i'm going to try to figure it out.