-
Notifications
You must be signed in to change notification settings - Fork 448
Fix #195 Added Migration code for sqlite files from Document to Application Support folder #1026
Conversation
9aa1aae
to
1c170e7
Compare
Client/Application/AppDelegate.swift
Outdated
@@ -64,6 +64,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIViewControllerRestorati | |||
|
|||
HttpsEverywhereStats.shared.startLoading() | |||
|
|||
//Moves Coredata sqlite file from Documents dir to application support dir. | |||
DataController.shared.migrateToNewPathIfNeeded() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably move this into the migration, and just let the migration call below handle this if possible. Is there a timing issue or something?
Best not to require different migrations to happen at different places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I need the db migration to run before any db access. If I can enforce that no one will ever write anything DB before migration code then we can move it there. Any ideas we can do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless there are issues right now, I think this is relatively safe to assume. Migrations should generally always happen before DB access, and hasn't been an issue this far (famous last words, right?).
Also, it would only matter if we accessed the DB before someone had this migration take place, so after a couple months, this migration will likely not be very useful/important.
If we have genuine concerns about this, we should consider moving the entire migration process up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in DM, The placement of the db migration is curcial because of !DataController.shared.storeExists()
check. Create a facade for the DB migration in Migration Code though.
Data/models/DataController.swift
Outdated
fileprivate extension URL { | ||
|
||
func sqliteFiles(dbName: String) throws -> [URL] { | ||
return try FileManager.default.contentsOfDirectory(at: self, includingPropertiesForKeys: nil, options: []).filter({$0.lastPathComponent.hasPrefix(dbName)}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't that retrieve all files, not only with .sqlite extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes thats intended. I want to retrieve all files that have a name prefix Brave.sqlite
like Brave.sqlite-wal
etc. I think keeping this function in an extension may not be the best way, so moving it into the migration method itself.
8e8323a
to
fd7b1ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good
Client/Application/AppDelegate.swift
Outdated
@@ -64,8 +64,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIViewControllerRestorati | |||
|
|||
HttpsEverywhereStats.shared.startLoading() | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
fd7b1ba
to
ea25db6
Compare
Joel Discussed the issue he had with Danish and DM and agreed to leave it as it is
Sqlite file is now migrated to the new folder. There two questions that need to be answered/invetigated before merge.
Fore Example:
https-everywhere-data
folder and Locally saved cookies(can be moved to Application support).Submitter Checklist:
Fix #123: This fixes the shattered coffee cup!
(orNo Bug: <message>
if no relevant ticket)NSLocalizableString()
Test Plan:
We have to test if the app upgrades correctly so:
Screenshots:
Before:


After:
Reviewer Checklist:
QA/(Yes|No)
release-notes/(include|exclude)
bug
/enhancement