feat: configurable root path for read-only environments#26
Open
edgett wants to merge 1 commit intomanagedcode:mainfrom
Open
feat: configurable root path for read-only environments#26edgett wants to merge 1 commit intomanagedcode:mainfrom
edgett wants to merge 1 commit intomanagedcode:mainfrom
Conversation
Replace hardcoded Environment.CurrentDirectory root in MarkItDownPathResolver with a lock-guarded, configurable init so Azure Functions and other read-only hosts can redirect workspaces to a writable directory. - MarkItDownPathResolver: lock-guarded double-check init with Configure(string) and platform-aware path comparison - MarkItDownOptions.RootPath for non-DI callers - MarkItDownServiceBuilder.UseRootPath() for DI callers - Wired in MarkItDownClient constructor before any other init Co-authored-by: Cursor <cursoragent@cursor.com>
Author
|
I verfied:
|
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
MarkItDownPathResolverhardcodes.markitdownunderEnvironment.CurrentDirectory, which is read-only in Azure Functions (and similar containerized/serverless environments), crashing on the first conversion.Lazy<string>in the resolver with a lock-guarded double-check init pattern and added aConfigure(string)method so the root can be redirected before any conversion runs.MarkItDownOptions.RootPathfor non-DI callers andMarkItDownServiceBuilder.UseRootPath()for DI callers.Usage
DI (Program.cs):
Non-DI:
Safety
Configure()andRootPathfirst-access share a single lock -- no race window between writing the config and materializing the root.InvalidOperationExceptioninstead of silently ignoring.Path.GetFullPath()with platform-aware comparison (case-insensitive on Windows, ordinal on Linux).Files changed
src/MarkItDown/Utilities/MarkItDownPathResolver.cs-- core fix (lock-guarded init +Configure)src/MarkItDown/Core/MarkItDownOptions.cs-- addedRootPathpropertysrc/MarkItDown/Core/MarkItDownClient.cs-- 2 lines wiringRootPathin constructorsrc/MarkItDown/DependencyInjection/MarkItDownServiceBuilder.cs-- addedUseRootPath()methodAGENTS.md-- documented the configurability ruleTest plan
RootPathto temp folder resolves the crash