Swift: Replacing sqlite file fails - ios

I am working on an App for iPhone and I try to develop a backup function for my sqlite database to the users dropbox:
If the user is doing a (manual) backup, my file „myDatabase.sqlite3“ is copied to a selected folder in the dropbox.
If the user imports the backup, I am replacing the „myDatabase.sqlite3“ file with the one from the dropbox. After this, all Selects on the database fail with the error „[logging] disk I/O error in „SELECT…“. BUT if I restart my app, everything works great!
So I think it’s something missing with the connection (of course I opened a new connection after replacing the file)? Maybe something isn’t refreshed or rebuild? What am I missing? I don’t have these *-shm and *-wal files I read about in some tutorials.
Thanks a lot for your help, I have spent hours and days trying everything I could find…

I found the mistake: it was a timing problem... I opened the new connection while the copy process hasn't finished!

Related

uWSGI trying to load non-existing ini

so I have been trying to add a python app to uwsgi, but it was failing and I decided to redo (and also rename) the application. So I deleted old ini file from /etc/uwsgi/sites-available (lets call it 'example1.ini' and also the application directory from the server ('example1').
Then I uploaded a new directory (lets call it 'example2') and created a new ini file called 'example2.ini'. I also created a symlink.
Now when I try to restart uwsgi, it fails and when I see its status it is trying to load the old ini file (example1.ini) and it causes it to fail. In addition to that, it does not even load the new app.
Is there any way to reload all apps/remove cache/refresh the configurations?
Update: I hope this helps someone. There was no obvious fix so I tried to reboot the whole server (computer) and it helped.

error 75 path/file access lotus notes while deleting files

I have a lotus notes agent which takes some files from the server and does some processing and then deletes those files.
For deleting we have used the Kill command. It was working fine, but now we are getting the error "path/file access". Could anyone please help me on this.
If the files are NSF files and your code is opening them as NotesDatabase objects via the server, the files on disk will not be closed even after you are done using them and the objects are gone. That's because the server maintains a cache of open NSF files. You cannot delete the files until they are out of the cache. (This may or may not be true if you specified "" instead of the server name when you opened the NotesDatabase object. I don't recall, but if the workaround had been as easy as just opening locally using "", I think we would have done that.)
To get around this in the past, what I have done is just leave the files on disk and write another agent that runs once per day to clean them up. It's ugly, but it was the only way to deal with the problem.

MagicalRecord SQLite file empty

I am having problem reading a file. I'm using MagicalRecord as my CoreData wrapper. I successfully save or update object. With my NSLog I can see it, everything is fine and I can use it in my database. But every time I want to see SQLite file with my application (I'm using Datum LE), file is empty. I cannot access that file directly within my Library folder in my app. I copy that file to my desktop and it is empty. What am I doing wrong? So once more, everything inside my iOS application works fine, I can see records being saved and I can fetch them normally.
You are clearly looking at the wrong file. If your app is saving (I assume, across app restarts), the date is definitely saved.
One way to find out is to NSLog the persistent store URL and check the referenced file.
I believe the issue you are encountering is the new default journaling mode that Core Data uses.
See this article
https://developer.apple.com/library/ios/qa/qa1809/_index.html
Basically your changes are not written to the .sqlite file, but are found in .sqlite-wal. HOWEVER, most SQLite reading apps I have tried blow away the -wal when you open the .sqlite, so good luck.
You could try changing the journaling mode for debugging purposes

Updating an iOS app on the AppStore which uses CoreData

I know there are similar questions on this subject but nothing that quite answers my query. I am aware that it is a bit of a newbie question!
I have an app on the AppStore which I will soon be looking to update. My binary contains a pre-loaded sqlite file with a list of data which the user starts off with. However, the user will extensively edit this information and it is crucial that that data is maintained through the update.
I am not changing the CoreData structure at all so won't be performing any migration but my concern is that when I upload the new binary the packaged sqlite file will overwrite the users existing data. I suspect that won't be the case but can anyone shed any light on it?
When updating an application the documents directory is untouched. Presumably your startup code checks to see if you have already copied the initial database from the bundle to the documents directory - this will work the same way after an upgrade.
You are testing this every time you run a new build on your device during development anyway - you've put a whole new version of the app bundle on there, and it doesn't kill all your data, does it? (does it???)

iOS application update problem with files in documents directory

Oddest issue, thought I would see if anyone had run into this before.
We have an iPad application that stores PDF files in the documents directory. All goes great, we can open the PDF's with CGPDFDocumentCreateWithURL all day long. Then, we reinstall the application from the same adhoc site, and for some reason are not able to load the files. We can iterate the documents folder, see the files there, but can't open them. We just get a nil back from CGPDFDocumentCreateWithURL.
This feels very much like the permissions on the files change after the update, but can't prove that.
So, has anyone encountered this post update? Is there anyway to get a error return from CGPDFDocumentCreateWithURL?
We encountered a similar problem recently and perhaps the same is happening to you.
Are you using the complete URL/path which you had (probably) saved before you updated the application.
The reason is that the App_Home directory changes on updates. So if earlier it was:
/var/mobile/applications/<guid1>/
after the update it will become
/var/mobile/applications/<guid2>/
The solution is to save relative paths from App_Home directory.

Resources