Repository navigation
fix(json): keep dots in SetFromDirectory keys - #603
Open
pcbeingused33 wants to merge 1 commit into
Open
pcbeingused33 wants to merge 1 commit into
pcbeingused33 wants to merge 1 commit into
Conversation
SetFromDirectory and SetFromDirectoryAsync derived the key by cutting the file path at its first dot, so a dot in a directory or file name (or a leading "./") truncated the key. Only the file extension is removed now.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This branch has not been deployed
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.
JSON().SetFromDirectory/SetFromDirectoryAsyncstore documents under the wrong key when the path of a file contains a dot anywhere before the.jsonextension.Root cause: the key is built with
filePath.Substring(0, filePath.IndexOf(".")), which cuts the path at its first dot instead of at the extension. ForBase.Dir/v1.2/json.File1.jsonthe key becomesBase, so every file under that directory is written to the same key and overwrites the previous one. A relative path that starts with./yields an empty key.Fix: remove only the extension with
Path.ChangeExtension(filePath, null), in both the sync and async implementations. Keys for paths without extra dots are unchanged.Test:
TestSetFromDirectoryWithDotsInPathandTestSetFromDirectoryWithDotsInPathAsyncload a file from a directory tree with dots in the directory and file names and read it back under<path without .json>. Both fail before the change (the key does not exist) and pass after. Run on net8.0 against a standalone Redis 8 server, together with the existingTestSetFromDirectory*tests; the cluster variants were skipped locally.Disclosure: this change was prepared with the assistance of an AI tool (Claude).