Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class RegisterWatchlistMembersFromDirCmd
[Option("-p|--parallel", "Max degree of parallelism, default value is 1", CommandOptionType.SingleValue)]
public int MaxDegreeOfParallelism { get; set; } = 1;

[Option("--fileNameAs", "Use file name as ID, FullName", CommandOptionType.SingleValue)]
[Option("--fileNameAs", "Use file name as ID or FullName", CommandOptionType.SingleValue)]
public string FileNameToProperty { get; set; } = "id";

public RegisterWatchlistMembersFromDirCmd(IWatchlistMemberRegistrationManager registrationManager, ILogger<RegisterWatchlistMembersFromDirCmd> logger)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public WatchlistMemberMetadata[] GetWatchlistMemberRegistrationData(string path)
{
MatchCasing = MatchCasing.CaseInsensitive
});

if (files.Length == 0)
{
throw new ProcessingException($"Selected directory does not contain any json file with RegisterWatchlistMemberExtended data [{path}]");
Expand All @@ -41,7 +41,32 @@ public WatchlistMemberMetadata[] GetWatchlistMemberRegistrationData(string path)

var content = File.ReadAllText(file);
var result = JsonConvert.DeserializeObject<WatchlistMemberMetadata[]>(content);

foreach (var metadata in result)
{
metadata.PhotoFiles = metadata.PhotoFiles.Select(s => NormalizePhotoPath(path, s)).ToArray();
}

return result;
}

private string NormalizePhotoPath(string directory, string photoFile)
{
if (string.IsNullOrEmpty(photoFile))
{
return photoFile;
}

if (Path.IsPathRooted(photoFile))
{
return photoFile;
}

var normalizedPhotoPath = Path.Combine(directory, photoFile);

Log.LogInformation($"PhotoFile {photoFile} is relative, normalize to rooted path : {normalizedPhotoPath}");

return normalizedPhotoPath;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ private IEnumerable<WatchlistMemberRegisterData> BuildWatchlistMemberRegisterDat
break;

case "name":
case "fullname":
watchlistMemberPhotoPaths.Add(new WatchlistMemberPhotoPath() { Name = validFileName, PhotoPath = file });
break;
}
Expand Down