Repository navigation
fix(placement): judge every build item, not every object id (#93) #102
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
6cae03d
fix(placement): judge every build item, not every object id (#93)
DVOpenLabs 8af1b89
fix(placement): key by part, never treat unjudged instances as fine (…
DVOpenLabs 5481f6f
fix(placement): bound the footprint read; number instances per (part,…
DVOpenLabs d75ce0c
fix(placement): printable area not travel, no OK for unjudged or tall…
DVOpenLabs f864846
fix(placement): content-keyed Ready Now cache, height from printing p…
DVOpenLabs 7a66d7b
fix(placement): below-plate parts, torn Ready Now reads, named printe…
DVOpenLabs 32bb332
fix(placement): printing roles propagate down through assemblies (#93…
DVOpenLabs ac6d446
fix(placement): role-aware overall extents; Orca precise-seam helper …
DVOpenLabs cabbbdf
test(placement): the cross-consumer test also drives service.bed_fit …
DVOpenLabs f194612
Merge feat/scene-contract (on main v1.6.0) into fix/93-repeated-insta…
DVOpenLabs 8b8ddca
fix(placement): role-aware overall extents without unit conversion; v…
DVOpenLabs 4c5a07c
fix(placement): no placement, height or plate verdict without an esta…
DVOpenLabs 21f0abb
fix(layout): plate-fit layout check is not checked when physical size…
DVOpenLabs 91b1066
Merge main into fix/93-repeated-instances
DVOpenLabs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| """What identifies a file's CONTENT for anything that remembers a result about it. | ||
|
|
||
| A remembered result is only as good as its key. Size and modification time alone miss a same-size | ||
| replacement that kept its timestamp (a copy that preserves times, a tool that rewrites in place), so the | ||
| key also carries a fingerprint of the bytes, and a result is only stored if the file is unchanged after it | ||
| was computed. | ||
| """ | ||
| from __future__ import annotations | ||
|
|
||
| import hashlib | ||
| import zipfile | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| def stat_identity(path: str): | ||
| """``(resolved path, mtime, size)`` or None.""" | ||
| try: | ||
| resolved = Path(path).resolve() | ||
| st = resolved.stat() | ||
| except OSError: | ||
| return None | ||
| return (str(resolved), st.st_mtime_ns, st.st_size) | ||
|
|
||
|
|
||
| def file_identity(path: str): | ||
| """The stat identity PLUS a fingerprint of the content, or None if the file cannot be read. | ||
|
|
||
| For a zip (every 3MF) the fingerprint is taken from the archive's own directory: each member's name, | ||
| size and CRC-32, which changes whenever any member's bytes do and costs a read of the directory only, | ||
| not of a 40 MB project. Anything else is hashed whole.""" | ||
| base = stat_identity(path) | ||
| if base is None: | ||
| return None | ||
| digest = hashlib.blake2b(digest_size=16) | ||
| try: | ||
| try: | ||
| with zipfile.ZipFile(path) as archive: | ||
| for info in archive.infolist(): | ||
| digest.update(f"{info.filename}|{info.file_size}|{info.CRC}|".encode("utf-8", "replace")) | ||
| except zipfile.BadZipFile: | ||
| with open(path, "rb") as fh: | ||
| for chunk in iter(lambda: fh.read(1 << 20), b""): | ||
| digest.update(chunk) | ||
| except OSError: | ||
| return None | ||
| return base + (digest.hexdigest(),) | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: DVOpenLabs/snapmaker-studio
Length of output: 7660
🏁 Script executed:
Repository: DVOpenLabs/snapmaker-studio
Length of output: 39720
🏁 Script executed:
Repository: DVOpenLabs/snapmaker-studio
Length of output: 31637
🏁 Script executed:
Repository: DVOpenLabs/snapmaker-studio
Length of output: 7065
Avoid hashing STL rows on every Ready Now scan.
Ready Now sends every library row to
_ready_one, including.stldownloads._ready_analysis_oncecallsfileid.file_identity(path)before the cache lookup and again after the analysis. For an STL, this hashes the complete file on both calls, even when the result is cached. A placement pass can cause additional calls.Keep content fingerprinting for 3MF files. A stat-only key would lose the same-size replacement protection. For STL rows, use a cheap existence/readability identity and skip placement assessment. STL traits depend only on the extension and file existence, and
plate_placement.assessonly opens 3MF projects.🧰 Tools
🪛 ast-grep (0.45.3)
[warning] 41-41: File path is request-/variable-derived; validate and normalize to prevent path traversal.
Context: open(path, "rb")
Note: [CWE-22] Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
(open-filename-from-request)
🤖 Prompt for AI Agents