Enumerating store files doesn't match filenames with whitespace (#287)

For example, the store name of "recording" works well, but if you have a store called "recording (1)" then the whitespace character was not being properly escaped
This commit is contained in:
Austin Hale 2023-06-23 16:57:01 -07:00 коммит произвёл GitHub
Родитель 7fa3d24675
Коммит d08fdd34f6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 5 добавлений и 4 удалений

Просмотреть файл

@ -73,13 +73,14 @@ namespace Microsoft.Psi.Persistence
internal static IEnumerable<FileInfo> EnumerateStoreFiles(string storeName, string storePath)
{
string escapedStoreName = Regex.Escape(storeName);
foreach (var fileName in Directory.EnumerateFiles(storePath))
{
var fileInfo = new FileInfo(fileName);
if (Regex.Match(fileInfo.Name, $@"^{storeName}\.Catalog_\d\d\d\d\d\d\.psi$").Success ||
Regex.Match(fileInfo.Name, $@"^{storeName}\.Data_\d\d\d\d\d\d\.psi$").Success ||
Regex.Match(fileInfo.Name, $@"^{storeName}\.LargeData_\d\d\d\d\d\d\.psi$").Success ||
Regex.Match(fileInfo.Name, $@"^{storeName}\.Index_\d\d\d\d\d\d\.psi$").Success)
if (Regex.Match(fileInfo.Name, $@"^{escapedStoreName}\.Catalog_\d\d\d\d\d\d\.psi$").Success ||
Regex.Match(fileInfo.Name, $@"^{escapedStoreName}\.Data_\d\d\d\d\d\d\.psi$").Success ||
Regex.Match(fileInfo.Name, $@"^{escapedStoreName}\.LargeData_\d\d\d\d\d\d\.psi$").Success ||
Regex.Match(fileInfo.Name, $@"^{escapedStoreName}\.Index_\d\d\d\d\d\d\.psi$").Success)
{
yield return fileInfo;
}