Skip to content

Commit 4ad4dca

Browse files
author
Kapil Borle
committed
Check for module presence before copying
1 parent ea3c0ad commit 4ad4dca

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

Engine/Generic/ModuleDependencyHandler.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,7 @@ public void SaveModule(string moduleName)
263263
if (modulesSavedInTempPath.Contains(moduleName))
264264
{
265265
// copy to local ps module path
266-
CopyDir(Path.Combine(tempDirPath, moduleName), localPSModulePath);
267-
modulesSavedInModulePath.Add(moduleName);
266+
CopyToPSModulePath(moduleName);
268267
return;
269268
}
270269

@@ -278,9 +277,22 @@ public void SaveModule(string moduleName)
278277
moduleRepository));
279278
}
280279
SaveModule(module);
281-
modulesSavedInTempPath.Add(moduleName);
280+
modulesSavedInTempPath.Add(moduleName);
281+
CopyToPSModulePath(moduleName);
282+
}
282283

283-
// copy to local ps module path
284+
private void CopyToPSModulePath(string moduleName, bool checkModulePresence = false)
285+
{
286+
if (checkModulePresence)
287+
{
288+
foreach(var dir in Directory.EnumerateDirectories(localPSModulePath))
289+
{
290+
if (Path.GetFileName(dir).Equals(moduleName, StringComparison.OrdinalIgnoreCase))
291+
{
292+
return;
293+
}
294+
}
295+
}
284296
CopyDir(Path.Combine(tempDirPath, moduleName), localPSModulePath);
285297
modulesSavedInModulePath.Add(moduleName);
286298
}

0 commit comments

Comments
 (0)