Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sources/FluidAudio/Shared/Download/ModelHub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,9 @@ public enum ModelHub {
itemPath.hasSuffix(".json") || itemPath.hasSuffix(".model") || itemPath.hasSuffix(".bin")
return isInSubPath && (matchesPattern || isMetadata)
}
return patterns.isEmpty || patterns.contains { itemPath.hasPrefix($0) }
// Patterns carry a trailing "/" (bundle directories); a required root-level
// *file* (e.g. `tokenizer.model`) matches when the pattern is exactly its path.
return patterns.isEmpty || patterns.contains { itemPath.hasPrefix($0) || $0 == itemPath + "/" }
|| itemPath.hasSuffix(".json") || itemPath.hasSuffix(".txt")
}
}
Expand Down
15 changes: 15 additions & 0 deletions Tests/FluidAudioTests/Shared/ModelHubIncludeRuleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,19 @@ final class ModelHubIncludeRuleTests: XCTestCase {
XCTAssertTrue(rule("vocab.txt", false))
XCTAssertFalse(rule("Other.mlmodelc/model.mil", false))
}

// MARK: - Root-level repo with a required non-JSON file

func testRequiredRootFileWithoutMetadataExtensionIncluded() {
// `tokenizer.model` is a required file at the repo root. Patterns carry a
// trailing "/", so a prefix match alone never admitted it and the verify
// pass threw `modelNotFound`.
let include = ModelHub.repoIncludeRule(
subPath: nil, patterns: ["Frame.mlmodelc/", "config.json/", "tokenizer.model/"])
XCTAssertTrue(include("tokenizer.model", false))
XCTAssertTrue(include("config.json", false))
XCTAssertTrue(include("Frame.mlmodelc/model.mil", false))
XCTAssertFalse(include("tokenizer_test_vectors.model", false))
XCTAssertFalse(include("Encoder.mlmodelc/model.mil", false))
}
}
Loading