Owasp.SafeNuGet.Unsafe.PackageListLoader.GetCachedUnsafePackages C# (CSharp) Method

GetCachedUnsafePackages() public method

public GetCachedUnsafePackages ( string cachePath, int cacheTimeInMinutes, bool &cacheHit ) : UnsafePackages
cachePath string
cacheTimeInMinutes int
cacheHit bool
return UnsafePackages
        public UnsafePackages GetCachedUnsafePackages(string cachePath, int cacheTimeInMinutes, out bool cacheHit)
        {
            DirectoryInfo dir = new DirectoryInfo(cachePath);
            if (!dir.Exists) dir.Create();
            FileInfo file = new FileInfo(Path.Combine(dir.FullName, "unsafepackages.xml"));
            cacheHit = true;
            if (!file.Exists || file.LastWriteTime < DateTime.Now.AddMinutes(-cacheTimeInMinutes))
            {
                cacheHit = false;
                FileInfo newFile = new FileInfo(file.FullName + ".new");
                BuildWebClient().DownloadFile(PackageUrl, newFile.FullName);
                File.Copy(newFile.FullName, file.FullName, true);
            }
            using (var s = file.OpenRead())
            {
                return LoadPackages(s);
            }
        }