-
Notifications
You must be signed in to change notification settings - Fork 6
Fix broken local uri's when relaunching the app #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix broken local uri's when relaunching the app #74
Conversation
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.
Thanks! The fix here looks good to me.
I think it should be fine to run verifyAttachments
earlier (in addition to running it when syncing starts).
The simplest solution might be to expose a public method like verifyAttachments
which users can call before startSync
.
It appears very simple to just kick off this in the queue's constructor like this:
If there's no downsides to it, I would of course prefer it if the SDK fixed it automatically. More user friendly than having to realize why it's not working and how to fix it.
Do you want me to add this, or prefer a more cautious approach of just exposing it like:
|
E.g. when rebuilding an app the system relocates the app's sandbox which gets a new path each run, which breaks the stored local uri's
Actually, this bug affects real devices as well. So might be a bit more serious than I first thought. I misremembered that it's only simulators that get an updated app sandbox URL (probably because I usually don't debug filesystem-stuff on devices, since you can't browse it in Finder).
I think my fix does work but think it's probably a good idea to try and avoid storing absolute paths all together (e.g. shouldn't filename + attachmentsDirectory be enough?). This Technical Note TN2406 does say:
And this on Locating Files Using Bookmarks:
https://stackoverflow.com/questions/47864143/document-directory-path-change-when-rebuild-application |
I had a bunch of these, not sure if they got in that state from my experimenting/testing with broken local uri's (before arriving at the fix in the previous commit fcadf00)
To repair broken localUri's without requiring start sync, e.g. using an app before signing in/subscribing
6d12c30
to
7c64b47
Compare
@jonkan Thank you for the detailed updates. I was not aware that the absolute path would change on an actual device, this is definitely more concerning. I'm not against kicking off the task in the background in the initializer. I think having some method of indicating that the verification has completed would be nice though. E.g. some indication that the attachments present are ready to be used. This becomes slightly trickier to implement since you'd need to track a reference to the spawned Task and the Task captures
This is a fair point. Currently the |
@stevensJourney Ok. Adding a Personally I don't (currently) see any of these as strictly necessary, not sure what issues they fix. Maybe it can be tracked/discussed in a separate issue? That being said, I'll happily do any of them in order to get this merged. I do need the bug fixed. |
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.
@jonkan Thanks. This looks good to me. I'll add some minor items like a changelog entry and potentially some of the items mentioned above in a follow up PR.
Hey! I asked about this in the discord as well.
Since simulators update the path to the app's sandbox each time the app is run I'm hitting this issue where the local uri's stored in the database break the next time I run the app.
What I've observed:
State A: clean slate, not signed in, no sync enabled (yet).
State B, already signed in:
I've created a partial fix in this PR, by updating the local uri's in the verifyAttachments. The issue that remains is that verifyAttachments isn't run until sync is enabled. I.e. I'm still hitting the bug in State A until step 2.
Can we run verify earlier? Other input/ideas?
Also, this should only be an issue when running on a Simulator. Not for real devices.