示例#1
0
 public HostedPackage ToHostedPackage(ServerPackage serverPackage)
 {
     if (serverPackage == null)
     {
         return(null);
     }
     return(new HostedPackage(new ODataPackage(serverPackage)));
 }
示例#2
0
        public ServerPackage CreateServerPackage(LocalPackageInfo package, bool enableDelisting)
        {
            // File names
            var packageFileName = package.Path;
            var hashFileName    = Path.ChangeExtension(packageFileName, PackagingCoreConstants.HashFileExtension);

            // File system
            var physicalFileSystem = _fileSystem as PhysicalFileSystem;

            // Build package info
            var packageDerivedData = new PackageDerivedData();

            // Read package hash
            using (var reader = new StreamReader(_fileSystem.OpenFile(hashFileName)))
            {
                packageDerivedData.PackageHash = reader.ReadToEnd().Trim();
            }

            // Read package info
            var localPackage = package;

            if (physicalFileSystem != null)
            {
                // Read package info from file system
                var fileInfo = new FileInfo(packageFileName);
                packageDerivedData.PackageSize = fileInfo.Length;

                packageDerivedData.LastUpdated = _fileSystem.GetLastModified(packageFileName);
                packageDerivedData.Created     = _fileSystem.GetCreated(packageFileName);
                packageDerivedData.Path        = packageFileName;
                packageDerivedData.FullPath    = fileInfo.FullName;

                // if (enableDelisting && localPackage != null)
                // {
                //     // hidden packages are considered delisted
                //     localPackage.Listed = !fileInfo.Attributes.HasFlag(FileAttributes.Hidden);
                // }
            }
            else
            {
                throw new NotSupportedException("Read package info from package (slower)");
                // FIXME Read package info from package (slower)
                // using (var stream = package.GetStream())
                // {
                //     packageDerivedData.PackageSize = stream.Length;
                // }

                // packageDerivedData.LastUpdated = DateTime.MinValue;
                // packageDerivedData.Created = DateTime.MinValue;
            }

            // TODO: frameworks?

            // Build entry
            var serverPackage = new ServerPackage(package.Nuspec, packageDerivedData);

            return(serverPackage);
        }
示例#3
0
 private static void UpdateLatestDictionary(
     ConcurrentDictionary <string, ServerPackage> dictionary,
     ServerPackage package)
 {
     dictionary.AddOrUpdate(
         package.Id,
         package,
         (oldId, oldEntry) => oldEntry.Version < package.Version ? package : oldEntry);
 }
示例#4
0
        public void Remove(ServerPackage entity)
        {
            _syncLock.EnterWriteLock();
            try
            {
                _packages.Remove(entity);

                UpdateLatestVersions(_packages.Where(package =>
                                                     String.Equals(package.Id, entity.Id, StringComparison.OrdinalIgnoreCase)));

                _isDirty = true;
            }
            finally
            {
                _syncLock.ExitWriteLock();
            }
        }
示例#5
0
        HostedPackage IPackageService.FindPackage(string packageId, NuGetVersion version)
        {
            ServerPackage serverPackage = this.FindPackage(packageId, version);

            return(ToHostedPackage(serverPackage));
        }