Skip to content

Commit ffb9975

Browse files
committed
Removed more edge cases thats not needed anymore
1 parent 2e8a0e2 commit ffb9975

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

src/code/InstallHelper.cs

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private List<PSResourceInfo> ProcessRepositories(
187187
if (repository != null && repository.Length != 0)
188188
{
189189
// Write error and disregard repository entries containing wildcards.
190-
repository = Utils.ProcessNameWildcards(repository, removeWildcardEntries:false, out string[] errorMsgs, out _);
190+
repository = Utils.ProcessNameWildcards(repository, removeWildcardEntries: false, out string[] errorMsgs, out _);
191191
foreach (string error in errorMsgs)
192192
{
193193
_cmdletPassedIn.WriteError(new ErrorRecord(
@@ -231,7 +231,7 @@ private List<PSResourceInfo> ProcessRepositories(
231231
if (repositoriesToSearch != null && repositoriesToSearch.Count == 0)
232232
{
233233
_cmdletPassedIn.ThrowTerminatingError(new ErrorRecord(
234-
new PSArgumentException ("Cannot resolve -Repository name. Run 'Get-PSResourceRepository' to view all registered repositories."),
234+
new PSArgumentException("Cannot resolve -Repository name. Run 'Get-PSResourceRepository' to view all registered repositories."),
235235
"RepositoryNameIsNotResolved",
236236
ErrorCategory.InvalidArgument,
237237
_cmdletPassedIn));
@@ -305,7 +305,8 @@ private List<PSResourceInfo> ProcessRepositories(
305305
bool installDepsForRepo = skipDependencyCheck;
306306

307307
// If no more packages to install, then return
308-
if (_pkgNamesToInstall.Count == 0) {
308+
if (_pkgNamesToInstall.Count == 0)
309+
{
309310
return allPkgsInstalled;
310311
}
311312

@@ -329,14 +330,9 @@ private List<PSResourceInfo> ProcessRepositories(
329330
}
330331

331332
repositoryNamesToSearch.Add(repoName);
332-
if ((currentRepository.ApiVersion == PSRepositoryInfo.APIVersion.V3) && (!installDepsForRepo))
333-
{
334-
_cmdletPassedIn.WriteWarning("Installing dependencies is not currently supported for V3 server protocol repositories. The package will be installed without installing dependencies.");
335-
installDepsForRepo = true;
336-
}
337333

338-
var installedPkgs = InstallPackages(_pkgNamesToInstall.ToArray(), currentRepository, currentServer, currentResponseUtil, scope, skipDependencyCheck, findHelper);
339-
foreach (var pkg in installedPkgs)
334+
List<PSResourceInfo> installedPkgs = InstallPackages(_pkgNamesToInstall.ToArray(), currentRepository, currentServer, currentResponseUtil, scope, skipDependencyCheck, findHelper);
335+
foreach (PSResourceInfo pkg in installedPkgs)
340336
{
341337
_pkgNamesToInstall.RemoveAll(x => x.Equals(pkg.Name, StringComparison.InvariantCultureIgnoreCase));
342338
}
@@ -535,8 +531,10 @@ private void MoveFilesIntoInstallPath(
535531
File.Delete(Path.Combine(finalModuleVersionDir, pkgInfo.Name + PSScriptFileExt));
536532
}
537533
}
538-
else {
539-
if (_includeXml) {
534+
else
535+
{
536+
if (_includeXml)
537+
{
540538
_cmdletPassedIn.WriteVerbose(string.Format("Moving '{0}' to '{1}'", Path.Combine(dirNameVersion, scriptXML), Path.Combine(installPath, scriptXML)));
541539
Utils.MoveFiles(Path.Combine(dirNameVersion, scriptXML), Path.Combine(installPath, scriptXML));
542540
}
@@ -614,11 +612,6 @@ private List<PSResourceInfo> InstallPackages(
614612

615613
if (!skipDependencyCheck)
616614
{
617-
if (currentServer.Repository.ApiVersion == PSRepositoryInfo.APIVersion.V3)
618-
{
619-
_cmdletPassedIn.WriteWarning("Installing dependencies is not currently supported for V3 server protocol repositories. The package will be installed without installing dependencies.");
620-
}
621-
622615
// Get the dependencies from the installed package.
623616
if (parentPkgObj.Dependencies.Length > 0)
624617
{
@@ -748,7 +741,7 @@ private Hashtable BeginPackageInstall(
748741
return packagesHash;
749742
}
750743

751-
break;
744+
break;
752745

753746
case VersionType.SpecificVersion:
754747
string nugetVersionString = specificVersion.ToNormalizedString(); // 3.0.17-beta
@@ -802,7 +795,9 @@ private Hashtable BeginPackageInstall(
802795

803796
break;
804797
}
805-
} else {
798+
}
799+
else
800+
{
806801
pkgToInstall = currentResult.returnedObject;
807802

808803
break;
@@ -816,11 +811,13 @@ private Hashtable BeginPackageInstall(
816811

817812
pkgToInstall.RepositorySourceLocation = repository.Uri.ToString();
818813
pkgToInstall.AdditionalMetadata.TryGetValue("NormalizedVersion", out string pkgVersion);
819-
if (pkgVersion == null) {
814+
if (pkgVersion == null)
815+
{
820816
// Not all NuGet providers (e.g. Artifactory, possibly others) send NormalizedVersion in NuGet package responses.
821817
// If they don't, we need to manually construct the combined version+prerelease from pkgToInstall.Version and the prerelease string.
822818
pkgVersion = pkgToInstall.Version.ToString();
823-
if (!String.IsNullOrEmpty(pkgToInstall.Prerelease)) {
819+
if (!String.IsNullOrEmpty(pkgToInstall.Prerelease))
820+
{
824821
pkgVersion += $"-{pkgToInstall.Prerelease}";
825822
}
826823
}
@@ -913,11 +910,11 @@ private string CreateInstallationTempPath()
913910
try
914911
{
915912
var dir = Directory.CreateDirectory(tempInstallPath); // should check it gets created properly
916-
// To delete file attributes from the existing ones get the current file attributes first and use AND (&) operator
917-
// with a mask (bitwise complement of desired attributes combination).
918-
// TODO: check the attributes and if it's read only then set it
919-
// attribute may be inherited from the parent
920-
// TODO: are there Linux accommodations we need to consider here?
913+
// To delete file attributes from the existing ones get the current file attributes first and use AND (&) operator
914+
// with a mask (bitwise complement of desired attributes combination).
915+
// TODO: check the attributes and if it's read only then set it
916+
// attribute may be inherited from the parent
917+
// TODO: are there Linux accommodations we need to consider here?
921918
dir.Attributes &= ~FileAttributes.ReadOnly;
922919
}
923920
catch (Exception e)
@@ -995,7 +992,8 @@ private bool TryInstallToTempPath(
995992
bool isModule = File.Exists(moduleManifest);
996993
bool isScript = File.Exists(scriptPath);
997994

998-
if (!isModule && !isScript) {
995+
if (!isModule && !isScript)
996+
{
999997
scriptPath = "";
1000998
}
1001999

@@ -1374,7 +1372,8 @@ private bool CallAcceptLicense(PSResourceInfo p, string moduleManifest, string t
13741372
new ArgumentException($"Package '{p.Name}' could not be installed: License.txt not found. License.txt must be provided when user license acceptance is required."),
13751373
"LicenseTxtNotFound",
13761374
ErrorCategory.ObjectNotFound,
1377-
_cmdletPassedIn);;
1375+
_cmdletPassedIn);
1376+
;
13781377
success = false;
13791378

13801379
return success;

0 commit comments

Comments
 (0)