Exemple #1
0
        public ReleaseDTO GetRelease()
        {
            ReleaseManifestDTO manifest = getManifest();
            IEnumerable <File> files    = getAllFiles(new List <string> {
            });

            return(new ReleaseDTO(manifest, files));
        }
Exemple #2
0
        private ReleaseManifestDTO getManifest()
        {
            ItemLocation manifestLocation = new ItemLocation("", ReleaseManifestDTO.FileName);
            File         manifestFile     = GetFile(manifestLocation);

            byte[]             content  = manifestFile.GetContent();
            ReleaseManifestDTO manifest = ReleaseManifestDTO.FromString(Encoding.Unicode.GetString(content));

            return(manifest);
        }
Exemple #3
0
        public void Upload(IEnumerable <File> release, ReleaseManifestDTO.Status statusOfRelease)
        {
            if (release == null)
            {
                throw new ArgumentNullException(nameof(release));
            }

            if (statusOfRelease == ReleaseManifestDTO.Status.Invalid)
            {
                throw new ArgumentException($"Invalid Status: {statusOfRelease}");
            }

            ReleaseManifestDTO manifest = generateNewManifest(release, statusOfRelease);

            var toUpload = new ReleaseDTO(manifest, release);

            Upload(toUpload);
        }
Exemple #4
0
        private ReleaseManifestDTO generateNewManifest(IEnumerable <File> release, ReleaseManifestDTO.Status statusOfRelease)
        {
            //creating the release requires the latest version ID.

            //The FTPclient will be pointing to the remote server.
            //At some point in the future, we will want a per-domain manifest to obtain this infomration quickly.

            ReleaseManifestDTO toReturn = new ReleaseManifestDTO();

            toReturn.NumberOfFiles = release.Count();
            toReturn.ReleaseStatus = statusOfRelease;

            //TODO: Determine the Hash
            //toReturn.Hash;
            toReturn.Version = this.getNextVersionNumber();



            return(toReturn);
        }
Exemple #5
0
        /// <summary>
        /// Contacts the remote server and re-downloads the specific release specified in the manifest, overwriting the current data.
        /// </summary>
        /// <param name="manifest"></param>
        private void Refresh(ReleaseManifestDTO manifest)
        {
            client.CurrentDirectory = CurrentDirectory;

            //The manifest contains the version number on the server.
            //This should match the folder name, if it doesn't, an invalid operation has occurred.
            if (manifest.Version != this.releaseNumber)
            {
                throw new InvalidOperationException($"Server folder: {this.RootFolder} {this.releaseNumber} does not match version found in manifest: {manifest.Version}.");
            }


            //TODO: This code is performance-sensitive and would be a good candidate to modify to use the async/await API.
            //Sadly FTPclient does not support this yet.
            //If we fix this, we could speed it up immensely.

            List <string> files = getFileNamesRecursively("").ToList();

            var memoryFiles = from path in files
                              select
                              new InMemoryFile(ItemLocation.FromRelativeFilePath(path), client.DownloadFile(path));

            this.ContainedFiles = this.SaveFiles(manifest, memoryFiles);
        }
Exemple #6
0
        public override void Refresh()
        {
            ReleaseManifestDTO r = this.getManifest();

            this.Refresh(this.getManifest());
        }
Exemple #7
0
 private ReleaseManifestDTO getManifest()
 {
     return(ReleaseManifestDTO.FromStream(client.DownloadFile(ReleaseManifestDTO.FileName)));
 }
Exemple #8
0
 private IEnumerable <File> SaveFiles(ReleaseManifestDTO manifest, IEnumerable <InMemoryFile> memoryFiles)
 {
     return(SaveRelease(new ReleaseDTO(manifest, memoryFiles)));
 }