Fix possible InvalidOperationException on OldName

I don't know how it's possible, MSDN docs don't mention it, but since it's nullable, this should help.
This commit is contained in:
JustArchi
2022-11-27 14:25:03 +01:00
parent 239c536815
commit 4816cd006d

View File

@@ -822,24 +822,28 @@ public static class ASF {
ArgumentNullException.ThrowIfNull(sender);
ArgumentNullException.ThrowIfNull(e);
if (string.IsNullOrEmpty(e.OldName)) {
throw new InvalidOperationException(nameof(e.OldName));
}
if (string.IsNullOrEmpty(e.OldFullPath)) {
throw new InvalidOperationException(nameof(e.OldFullPath));
}
if (string.IsNullOrEmpty(e.Name)) {
throw new InvalidOperationException(nameof(e.Name));
}
if (string.IsNullOrEmpty(e.FullPath)) {
throw new InvalidOperationException(nameof(e.FullPath));
}
await OnDeletedFile(e.OldName, e.OldFullPath).ConfigureAwait(false);
await OnCreatedFile(e.Name, e.FullPath).ConfigureAwait(false);
string? oldName = e.OldName;
if (string.IsNullOrEmpty(oldName)) {
oldName = Path.GetFileName(e.OldFullPath);
}
string? name = e.Name;
if (string.IsNullOrEmpty(name)) {
name = Path.GetFileName(e.FullPath);
}
await OnDeletedFile(oldName, e.OldFullPath).ConfigureAwait(false);
await OnCreatedFile(name, e.FullPath).ConfigureAwait(false);
}
private static async Task RegisterBots() {