Skip to content

Commit cdc55ff

Browse files
committed
Dispose lock
1 parent 9d06224 commit cdc55ff

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎src/code/InstallHelper.cs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,9 @@ private ConcurrentDictionary<string, Hashtable> BeginPackageInstall(
815815
return InstallParentAndDependencyPackages(parentAndDeps, currentServer, tempInstallPath, packagesHash, updatedPackagesHash, pkgToInstall);
816816
}
817817
else {
818-
// If we don't install dependencies, we're only installing the parent pkg so we can short circut and simply install the parent pkg.
819-
Stream responseStream = currentServer.InstallPackage(pkgToInstall.Name, pkgVersion, true, out ErrorRecord installNameErrRecord);
818+
// If we don't install dependencies, we're only installing the parent pkg so we can short circut and simply install the parent pkg.
819+
// Dispose the stream once done: for local repositories this is a FileStream on the repository's .nupkg and leaving it open locks the file.
820+
using Stream responseStream = currentServer.InstallPackage(pkgToInstall.Name, pkgVersion, true, out ErrorRecord installNameErrRecord);
820821

821822
if (installNameErrRecord != null)
822823
{
@@ -868,7 +869,7 @@ private ConcurrentDictionary<string, Hashtable> InstallParentAndDependencyPackag
868869
verboseMsgs.Enqueue($"Installing package '{depPkgName}' version '{depPkgVersion}'");
869870
//Stream responseStream = currentServer.InstallPackage(depPkgName, depPkgVersion, true, out ErrorRecord installNameErrRecord);
870871
// add async
871-
Stream responseStream = currentServer.InstallPackageAsync(depPkgName, depPkgVersion, true, errorMsgs, warningMsgs, debugMsgs, verboseMsgs).GetAwaiter().GetResult();
872+
using Stream responseStream = currentServer.InstallPackageAsync(depPkgName, depPkgVersion, true, errorMsgs, warningMsgs, debugMsgs, verboseMsgs).GetAwaiter().GetResult();
872873

873874
if (errorMsgs.Count > 0)
874875
{
@@ -906,7 +907,7 @@ private ConcurrentDictionary<string, Hashtable> InstallParentAndDependencyPackag
906907
{
907908
var pkgToInstallName = pkgToBeInstalled.Name;
908909
var pkgToInstallVersion = Utils.GetFullVersionString(pkgToBeInstalled.Version.ToString(), pkgToBeInstalled.Prerelease);
909-
Stream responseStream = currentServer.InstallPackage(pkgToInstallName, pkgToInstallVersion, true, out ErrorRecord installNameErrRecord);
910+
using Stream responseStream = currentServer.InstallPackage(pkgToInstallName, pkgToInstallVersion, true, out ErrorRecord installNameErrRecord);
910911

911912
if (installNameErrRecord != null)
912913
{

0 commit comments

Comments
 (0)