Ejemplo n.º 1
0
 public LocalPackageInfo(PackageReference reference, PackageDownloadInfo downloadStatus, Dto.PackageHashes hashes, Dto.PackageMeta metadata, PackageSequenceInfo sequence)
 {
     LockProvider    = new PackageLocks();
     DownloadMeasure = new MeasureItem(MeasureType.Throughput);
     UploadMeasure   = new MeasureItem(MeasureType.Throughput);
     Reference       = reference ?? throw new ArgumentNullException(nameof(reference));
     DownloadStatus  = downloadStatus ?? throw new ArgumentNullException(nameof(downloadStatus));
     Hashes          = hashes ?? throw new ArgumentNullException(nameof(hashes));
     Metadata        = metadata ?? throw new ArgumentNullException(nameof(metadata));
     Sequence        = sequence ?? throw new ArgumentNullException(nameof(sequence));
     if (!Reference.Id.Equals(DownloadStatus.PackageId))
     {
         throw new ArgumentException("Invalid hash.", nameof(downloadStatus));
     }
     if (!Reference.Id.Equals(Hashes.PackageId))
     {
         throw new ArgumentException("Invalid hash.", nameof(hashes));
     }
     if (!Reference.Id.Equals(Metadata.PackageId))
     {
         throw new ArgumentException("Invalid hash.", nameof(metadata));
     }
     if (!Metadata.PackageSize.Equals(Sequence.PackageSize))
     {
         throw new ArgumentException("Invalid size of package sequence.", nameof(sequence));
     }
 }
Ejemplo n.º 2
0
        public void UpdateMetadata(Dto.PackageMeta metadata, string directoryPath = null)
        {
            string path = Path.Combine(directoryPath ?? CreatePackagePath(metadata.PackageId), PackageMetaFileName);

            File.WriteAllBytes(path, app.MessageSerializer.Serialize(metadata));
        }