Skip to content

Commit

Permalink
Before this change calling OptimizedZipPackage.PurgeCache will delete…
Browse files Browse the repository at this point in the history
… ALL of the files under the nuget folder, affecting other clients.

With this change I moved the library to a new name (to avoid conflict with old versions), and created another layer of per-instance folder.
  • Loading branch information
Yishai Galatzer committed Dec 23, 2015
1 parent 92ce0fa commit eac0e51
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Core/Packages/OptimizedZipPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ namespace NuGet
/// Represents a NuGet package backed by a .nupkg file on disk.
/// </summary>
/// <remarks>
/// Unlike <see cref="ZipPackage"/>, OptimizedZipPackage doesn't store content files in memory.
/// Unlike <see cref="ZipPackage"/>, OptimizedZipPackage doesn't store content files in memory.
/// Instead, it unzips the .nupkg file to a temp folder on disk, which helps reduce overall memory usage.
/// </remarks>
public class OptimizedZipPackage : LocalPackage
{
// The DateTimeOffset entry stores the LastModifiedTime of the original .nupkg file that
// is passed to this class. This is so that we can invalidate the cache when the original
// file has changed.
private static readonly ConcurrentDictionary<PackageName, Tuple<string, DateTimeOffset>> _cachedExpandedFolder
private static readonly ConcurrentDictionary<PackageName, Tuple<string, DateTimeOffset>> _cachedExpandedFolder
= new ConcurrentDictionary<PackageName, Tuple<string, DateTimeOffset>>();
private static readonly IFileSystem _tempFileSystem = new PhysicalFileSystem(Path.Combine(Path.GetTempPath(), "nuget"));
private static readonly IFileSystem _tempFileSystem = new PhysicalFileSystem(
Path.Combine(Path.GetTempPath(), "NuGetScratch", Guid.NewGuid().ToString()));

private Dictionary<string, PhysicalPackageFile> _files;
private ICollection<FrameworkName> _supportedFrameworks;
Expand Down Expand Up @@ -268,7 +269,7 @@ where ZipPackage.IsPackageFile(part, package.PackageProperties.Identifier)
using (Stream partStream = file.GetStream(),
targetStream = _expandedFileSystem.OpenFile(filePath))
{
// if the target file already exists,
// if the target file already exists,
// don't copy file if the lengths are equal.
copyFile = partStream.Length != targetStream.Length;
}
Expand Down

0 comments on commit eac0e51

Please sign in to comment.