Skip to content

Commit

Permalink
Handle empty directories
Browse files Browse the repository at this point in the history
  • Loading branch information
Nice3point committed Sep 6, 2024
1 parent 9564ad1 commit 563b3b3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions source/DependenciesReport/AddinUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ public static IGrouping<string, string>[] GetAddinLocations()
var machineAddinsPath = Path.Combine(machineFolder, "Autodesk", "Revit", "Addins");
var storeAddinsPath = Path.Combine(machineFolder, "Autodesk", "ApplicationPlugins");

return Directory.EnumerateFiles(userAddinsPath, "*.addin", SearchOption.AllDirectories)
.Union(Directory.EnumerateFiles(machineAddinsPath, "*.addin", SearchOption.AllDirectories))
.Union(Directory.EnumerateFiles(storeAddinsPath, "*.addin", SearchOption.AllDirectories))
var addinFiles = Enumerable.Empty<string>();

if (Directory.Exists(userAddinsPath)) addinFiles = addinFiles.Union(EnumerateAddins(userAddinsPath));
if (Directory.Exists(machineAddinsPath)) addinFiles = addinFiles.Union(EnumerateAddins(machineAddinsPath));
if (Directory.Exists(storeAddinsPath)) addinFiles = addinFiles.Union(EnumerateAddins(storeAddinsPath));

return addinFiles
.GroupBy(file => Path.GetFileName(Path.GetDirectoryName(file))!)
.ToArray();
}
Expand Down Expand Up @@ -53,10 +57,15 @@ public static Dictionary<string, string> GetAddinDirectories(IGrouping<string, s
}
catch
{
Console.WriteLine($"Bad file: {manifest}");
Console.WriteLine($"Unsupported manifest: {manifest}. Skipped...");
}
}

return addinDirectories;
}

private static IEnumerable<string> EnumerateAddins(string folder)
{
return Directory.EnumerateFiles(folder, "*.addin", SearchOption.AllDirectories);
}
}
2 changes: 1 addition & 1 deletion source/DependenciesReport/DependenciesUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static List<DirectoryDescriptor> CreateDependenciesMap(Dictionary<string,
}
catch
{
Console.WriteLine($"Bad assembly: {assembly}");
Console.WriteLine($"Assembly without metadata: {assembly}. Skipped...");
}
}

Expand Down

0 comments on commit 563b3b3

Please sign in to comment.