Repository navigation
feat(services): persistent directory grants and in-place MediaURI - #2538
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements persistent directory access grants across app restarts and in-place read-only media playback URIs for files inside picked
core.Directorytrees:Persistent directory grants (
PickDirectoriesOptions.Persist,Directory.Token,Scope.OpenDirectory,Scope.ReleaseDirectory):FLAG_GRANT_READ_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSIONonACTION_OPEN_DOCUMENT_TREE(signaled via bit 31 ofITEM_PICK_DIRECTORIES's ignored limit word for wire compatibility with older prebuilt runtimes), callsContentResolver.takePersistableUriPermission, and handlesFOLDER_REOPEN/FOLDER_RELEASEovermsgFoldergated byCAP_FOLDER_PERSIST(4th capability byte bit32). Does not commitclasses.dexorclasses.jar.apple.CreateDirectoryBookmark(falling back to standard bookmarks in unsandboxed macOS builds), managesstartAccessingSecurityScopedResource/stopAccessingSecurityScopedResourcelifetimes, and refreshes stale bookmarks on reopen.Directory.Tokenempty and answerOpenDirectory/ReleaseDirectorywithcore.CodeUnavailable(driver.NoDirectoryPersistence).nsgotest: RecordsDirectoryPick.Persist, tracksApp.PersistedDirectories, supportsApp.OpenDirectory/App.ReleaseDirectoryhooks, and recordsApp.ReleasedDirectories.In-place media playback URIs (
Directory.MediaURI&core.ErrNoMediaURI):treeimplementsdriver.FolderMediaSourceto build the exactDocumentsContract.buildDocumentUriUsingTreecontent://document URI (including multi-user authorities such as10@...) in pure Go with zero IPC, ready forcore.Video{Source: uri}without copying files.Directory.Pathand formats them asfile://URLs viadriver.FilePathURL(POSIX, Windows drive, and UNC share).fs.FS: Returnscore.ErrNoMediaURI.Persistent Android descriptors &
io.ReaderAt:main(capFolderHandles,FolderHandles.java,io.ReaderAtondriver.FolderFSand Androiddocument), and automatically used by directories reopened viaScope.OpenDirectory.Docs, skills, and changelog:
docs/architecture/services.md,docs/public/en/services.md,docs/public/zh/services.md,skills/nsgo/SKILL.md,skills/nsgo/references/testing.md, and addedchangelog.d/persistent-dir-grants.md.Verification
javac -cp android-36/android.jar internal/platform/android/java/dev/oneo/nsgo/*.java): passedgo tool nsgo check -target macos,ios,windows_x64,linux_x64,android_arm64,web,harmonyos,watchos: all targets vetted cleanlygo tool nsgo test ./core: 961 passed, 0 failedgo tool nsgo test ./internal/driver: 224 passed, 0 failedgo tool nsgo test ./internal/platform/android: 155 passed, 0 failed, 10 skippedgo tool nsgo test ./internal/platform/apple: 203 passed, 0 failed, 2 skippedgo tool nsgo test ./nsgotest: 257 passed, 0 failed, 1 skippedgo tool nsgo test ./internal/moduletest: 17 passed, 0 failed, 1 skipped (TestSkills,TestLayering,TestPublicAPINamesNoInternalType)go tool nsgo test -run TestRepositoryFragments ./tools/changelog: 1 passed, 0 failedFixes #2245.
🤖 Gemini 4 Neon