Skip to content

Commit 6f2603f

Browse files
authored
Fix bug with import nickname (#2176)
## Description `.` is a special regex character, which means we weren't actually matching the `.` in the string, but rather the character before it. This resulted in the last letter in a model nickname getting cut off on import. This fix resolves that issue. ## Meta Merge checklist: - [x] Pull Request title is [short, imperative summary](https://cbea.ms/git-commit/) of proposed changes - [x] The description documents the _what_ and _why_ - [x] This PR has been [linted](https://docs.photonvision.org/en/latest/docs/contributing/linting.html). - [ ] If this PR changes behavior or adds a feature, user documentation is updated - [ ] If this PR touches photon-serde, all messages have been regenerated and hashes have not changed unexpectedly - [ ] If this PR touches configuration, this is backwards compatible with settings back to v2025.3.2 - [ ] If this PR touches pipeline settings or anything related to data exchange, the frontend typing is updated - [ ] If this PR addresses a bug, a regression test for it is added
1 parent f499e4f commit 6f2603f

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

photon-server/src/main/java/org/photonvision/server/RequestHandler.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -655,15 +655,11 @@ public static void onImportObjectDetectionModelRequest(Context ctx) {
655655
Files.copy(modelFileStream, modelPath, StandardCopyOption.REPLACE_EXISTING);
656656
}
657657

658+
int idx = modelFile.filename().lastIndexOf('.');
659+
String nickname = modelFile.filename().substring(0, idx);
660+
658661
ModelProperties modelProperties =
659-
new ModelProperties(
660-
modelPath,
661-
modelFile.filename().replaceAll("." + family.extension(), ""),
662-
labels,
663-
width,
664-
height,
665-
family,
666-
version);
662+
new ModelProperties(modelPath, nickname, labels, width, height, family, version);
667663

668664
ObjectDetector objDetector = null;
669665

0 commit comments

Comments
 (0)