Repository navigation
Conversation
hackmd_create_note now accepts an absolute local_path to a .md file in place of content. The server reads the file, so a large note no longer passes through the conversation. It creates the note, polls until the note reads back with exactly that body, then tracks the file the way hackmd_pull_note does. The reply summary says whether the file was tracked, and tracking.status carries tracked or not_tracked with a reason. A tracking failure is never an error once the POST has landed, because an error would invite a duplicate create. Publishing puts local file content on HackMD, so it is stricter than a plain create. It needs a workspace root set in the server's own environment, like an image upload, and an explicit read_permission, since HackMD's default for an omitted one is unmeasured. The path is checked before the POST and again before the record is written, so a symlink swapped in during the network calls leaves the file untracked. Refused before any request: a file that already has a sync record, a non-.md path, and local_path together with content. A file over the large-file warning size needs confirm_large_file: true. A LocalPathNotHandled error is the server's own mistake and is reported as an Internal error. The sync lock is held across the POST and read-back on purpose, so two publishes of one file cannot both win. Not run against the live API.
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.
hackmd_create_notetakes an absolutelocal_pathto a.mdfile in place ofcontent. The server reads the file, so a large note no longer passes through the conversation, creates the note, polls until it reads back with exactly that body, and then tracks the file the wayhackmd_pull_notedoes. The reply carriestracking.status(trackedornot_trackedwith a reason); a tracking failure is never an error once the POST has landed, because an error would invite a duplicate create.Publishing puts local file content on HackMD, so it is stricter than a plain create. It needs a workspace root set in the server's own environment, like an image upload, and an explicit
read_permission, since HackMD's default for an omitted one is unmeasured. The path is canonicalized and access-checked before the POST and compared again before the record is written, so a symlink swapped in during the network calls leaves the file untracked. A file that already has a sync record, a non-.mdpath, andlocal_pathtogether withcontentare refused before any request. A file over the large-file warning size needsconfirm_large_file: true.The logic lives in
src/sync/adopt.rs;src/note/crud.rsonly gains the two input fields and a guard thatcreate_noteitself never sees alocal_path.docs/tools.mdanddocs/configuration.mddescribe the new section and the root requirement.Verified locally:
cargo fmt --check,cargo clippy --all-targets --all-features -- -D warnings, andcargo test --all-targets --all-features(423 passed, 0 failed, 4 ignored), including six new tests insrc/sync/adopt.rsfor tracking, a differing read-back, a late read-back, the refusals, the root requirement, andcreate_noterefusing alocal_path. Not run against the live HackMD API.Left out: the capture-and-persist pair is still written out in pull and adopt, and the sync lock is held across the POST and read-back on purpose, so two publishes of one file cannot both win.
Summary by cubic
hackmd_create_notenow accepts an absolutelocal_pathto a.mdfile in place ofcontent. The server reads the file, creates the note, polls until it reads back with exactly that body, and then tracks the file the wayhackmd_pull_notedoes.tracking.status(tracked, ornot_trackedwith a reason) and the summary says which; a tracking failure is never an error after the POST, since an error would invite a duplicate create.read_permission; a file over the large-file warning size needsconfirm_large_file: true..mdpaths, andlocal_pathtogether withcontentare refused before any request.create_noteitself refuses alocal_pathas an internal error.Written for commit c2ac251. Summary will update on new commits.