public ReleaseDTO GetRelease() { ReleaseManifestDTO manifest = getManifest(); IEnumerable <File> files = getAllFiles(new List <string> { }); return(new ReleaseDTO(manifest, files)); }
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); }
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); }
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); }
/// <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); }
public override void Refresh() { ReleaseManifestDTO r = this.getManifest(); this.Refresh(this.getManifest()); }
private ReleaseManifestDTO getManifest() { return(ReleaseManifestDTO.FromStream(client.DownloadFile(ReleaseManifestDTO.FileName))); }
private IEnumerable <File> SaveFiles(ReleaseManifestDTO manifest, IEnumerable <InMemoryFile> memoryFiles) { return(SaveRelease(new ReleaseDTO(manifest, memoryFiles))); }