Skip to content
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 settings import #1385

Merged
merged 4 commits into from
Oct 15, 2024
Merged

Fix settings import #1385

merged 4 commits into from
Oct 15, 2024

Conversation

EricBAndrews
Copy link
Member

Checklist

  • I have read CONTRIBUTING.md
  • I have described what this PR contains
  • If this PR alters the UI, I have attached pictures/videos
  • This PR addresses one or more open issues that were assigned to me:
    - closes Unable the Import Settings #1373

Pull Request Information

Fixes an issue where settings could not be imported unless created explicitly by Mlem

Repro (on-device)

  • Export settings
  • Duplicate the settings file
  • Try to import the duplicated file
  • Import fails: "the file couldn't be opened because you don't have permission"

Resolution
Properly request access as defined in the docs

@EricBAndrews EricBAndrews requested a review from a team as a code owner October 13, 2024 17:35
@EricBAndrews EricBAndrews requested review from WestonHanners, JakeShirley and Sjmarf and removed request for a team October 13, 2024 17:35
Copy link
Contributor

@Sjmarf Sjmarf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Do we need to fileUrl.stopAccessingSecurityScopedResource() in the catch block? I'm not sure whether we're allowed to not call stopAccessingSecurityScopedResource and what the consequences of that would be

@EricBAndrews
Copy link
Member Author

Nice catch--I've updated the logic to call it in the catch as well.

Per the docs:

If you fail to relinquish your access to file-system resources when you no longer need them, your app leaks kernel resources. If sufficient kernel resources leak, your app loses its ability to add file-system locations to its sandbox, such as with Powerbox or security-scoped bookmarks, until relaunched.

Copy link
Contributor

@Sjmarf Sjmarf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@EricBAndrews EricBAndrews merged commit 3c47d47 into dev Oct 15, 2024
2 checks passed
@EricBAndrews EricBAndrews deleted the eric/file-import-fix branch October 15, 2024 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable the Import Settings
2 participants