Beispiel #1
0
        public override void InstallFile(RemoteAsset remoteAsset)
        {
            string outputPath = GetOutputPath(remoteAsset);

            Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
            remoteAsset.AssetContent.WriteAssetToFile(outputPath, false);
        }
Beispiel #2
0
        public void InstallProject(DownloadSession parentDownloadSession, string directory, string projectName, string projectVersion, uint?deployMode, string solutionName = null, string solutionVersion = null)
        {
            if (String.Equals(projectVersion, Constants.LatestVersionString))
            {
                projectVersion = GetLatestProjectRelease(projectName);
            }

            DownloadSession downloadSession = parentDownloadSession != null ? parentDownloadSession : new DownloadSession(String.Format("Installing project {0} (version {1})", projectName, projectVersion));

            downloadSession.ResetRegisteredFiles();

            ProjectRelease projectRelease = downloadSession.GetProjectRelease(projectName, projectVersion, this.LeagueCDNBaseURL);

            if (deployMode != null)
            {
                projectRelease.EnumerateFiles().ForEach(x => x.DeployMode = (ReleaseManifestFile.DeployMode)deployMode);
            }

            using (ProjectReleaseInstallation installation = new ProjectReleaseInstallation(projectRelease, directory, solutionName, solutionVersion))
            {
                foreach (ReleaseManifestFileEntry file in projectRelease.EnumerateFiles())
                {
                    RemoteAsset remoteAsset = projectRelease.GetRemoteAsset(file);
                    downloadSession.RegisterFile(remoteAsset, installation.GetFileInstaller(remoteAsset));
                }
                downloadSession.DoWork();

                if (parentDownloadSession == null)
                {
                    downloadSession.Dispose();
                }
            }
        }
        public void InstallProject(string directory, string projectName, string projectVersion, uint?deployMode, string solutionName = null, string solutionVersion = null)
        {
            if (String.Equals(projectVersion, Constants.LatestVersionString))
            {
                projectVersion = GetLatestProjectRelease(projectName);
            }

            Console.WriteLine("Downloading manifest for project {0}, release {1}...", projectName, projectVersion);
            ProjectRelease projectRelease = new ProjectRelease(projectName, projectVersion, this.LeagueCDNBaseURL);

            using (ProjectReleaseInstallation installation = new ProjectReleaseInstallation(projectRelease, directory, solutionName, solutionVersion))
            {
                foreach (ReleaseManifestFileEntry file in projectRelease.EnumerateFiles())
                {
                    RemoteAsset remoteAsset = projectRelease.GetRemoteAsset(file);
                    Console.Write("■ Downloading {0}/{1}", remoteAsset.StringVersion, remoteAsset.FileFullPath);
                    try
                    {
                        installation.InstallFile(remoteAsset);
                        Console.SetCursorPosition(0, Console.CursorTop);
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("■");
                    }
                    catch (Exception)
                    {
                        Console.SetCursorPosition(0, Console.CursorTop);
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("■");
                    }
                    Console.ResetColor();
                }
            }
        }
        private void DownloadFile(ProjectRelease projectRelease, ReleaseManifestFileEntry file, string fileOutputPath, string fileFullPath)
        {
            // Check if file is already downloaded and is in perfect condition.
            if (File.Exists(fileOutputPath) && Enumerable.SequenceEqual(file.MD5, CalculateMD5(fileOutputPath)))
            {
                return;
            }

            Directory.CreateDirectory(Path.GetDirectoryName(fileOutputPath));
            RemoteAsset remoteAsset = projectRelease.GetRemoteAsset(file);

            Console.Write("■ Downloading {0}/{1}", remoteAsset.StringVersion, fileFullPath);
            try
            {
                remoteAsset.AssetContent.WriteAssetToFile(fileOutputPath, false);
                Console.SetCursorPosition(0, Console.CursorTop);
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("■");
            }
            catch (Exception)
            {
                Console.SetCursorPosition(0, Console.CursorTop);
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("■");
            }
            Console.ResetColor();
        }
Beispiel #5
0
        public ProjectReleaseFileInstaller GetFileInstaller(RemoteAsset remoteAsset)
        {
            ProjectReleaseFileInstaller fileInstaller;

            switch (remoteAsset.FileEntry.DeployMode)
            {
            case RAFCompressed:
            case RAFRaw:
                fileInstaller = this.ProjectReleaseArchivedFileInstaller;
                break;

            case Managed:
                fileInstaller = this.ProjectReleaseManagedFileInstaller;
                break;

            case Deployed0:
            case Deployed4:
                fileInstaller = this.ProjectReleaseDeployedFileInstaller;
                break;

            default:
                throw new Exception("Unknown deploy mode");
            }
            return(fileInstaller);
        }
Beispiel #6
0
        public override bool IsFileInstalled(RemoteAsset remoteAsset)
        {
            string filePath = GetFilePath(remoteAsset);

            if (!File.Exists(filePath) || !Enumerable.SequenceEqual(remoteAsset.FileEntry.MD5, Utilities.CalculateMD5(filePath)))
            {
                return(false);
            }
            return(true);
        }
Beispiel #7
0
        public override void InstallFile(RemoteAsset remoteAsset)
        {
            string filePath = String.Format("{0}/{1}/{2}", this.ManagedFilesDirectory, remoteAsset.StringVersion, remoteAsset.FileFullPath);

            if (!File.Exists(filePath) || !Enumerable.SequenceEqual(remoteAsset.FileEntry.MD5, Utilities.CalculateMD5(filePath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(filePath));
                remoteAsset.AssetContent.WriteAssetToFile(filePath, false);
            }
        }
        public override void InstallFile(RemoteAsset remoteAsset)
        {
            string deployPath = GetFileDeployPath(remoteAsset);

            Directory.CreateDirectory(Path.GetDirectoryName(deployPath));
            remoteAsset.AssetContent.WriteAssetToFile(deployPath, false);

            if (this.SolutionReleaseDirectory != null && remoteAsset.FileEntry.DeployMode == Deployed4)
            {
                // File will also be in solution folder
                string solutionPath = GetFileSolutionPath(remoteAsset);
                Directory.CreateDirectory(Path.GetDirectoryName(solutionPath));
                File.Copy(deployPath, solutionPath);
            }
        }
        public override void InstallFile(RemoteAsset remoteAsset)
        {
            ArchiveVersionDirectory foundDirectory = this.GetArchiveDirectory(remoteAsset.StringVersion);

            foreach (RAF raf in foundDirectory.Archives)
            {
                RAFFileEntry fileEntry = raf.Files.Find(x => x.Path.Equals(remoteAsset.FileFullPath, StringComparison.InvariantCultureIgnoreCase));
                if (fileEntry != null)
                {
                    raf.Files.Remove(fileEntry);
                }
            }

            foundDirectory.Archives[0].AddFile(remoteAsset.FileFullPath, remoteAsset.AssetContent.GetAssetData(remoteAsset.FileEntry.DeployMode == RAFCompressed), false);
            foundDirectory.Archives[0].Save();
        }
        public override bool IsFileInstalled(RemoteAsset remoteAsset)
        {
            ArchiveVersionDirectory foundDirectory = this.GetArchiveDirectory(remoteAsset.StringVersion);

            foreach (RAF raf in foundDirectory.Archives)
            {
                RAFFileEntry fileEntry = raf.Files.Find(x => x.Path.Equals(remoteAsset.FileFullPath, StringComparison.InvariantCultureIgnoreCase));
                if (fileEntry != null)
                {
                    try
                    {
                        byte[] fileEntryContent = fileEntry.GetContent(remoteAsset.FileEntry.DeployMode == RAFCompressed);
                        return(Enumerable.SequenceEqual(remoteAsset.FileEntry.MD5, Utilities.CalculateMD5(fileEntryContent)));
                    }
                    catch (Exception) { return(false); }
                }
            }

            return(false);
        }
        public override void InstallFile(RemoteAsset remoteAsset)
        {
            string deployPath = String.Format("{0}/{1}", this.DeployDirectory, remoteAsset.FileFullPath);

            if (!File.Exists(deployPath) || !Enumerable.SequenceEqual(remoteAsset.FileEntry.MD5, Utilities.CalculateMD5(deployPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(deployPath));
                remoteAsset.AssetContent.WriteAssetToFile(deployPath, false);
            }
            if (this.SolutionReleaseDirectory != null && remoteAsset.FileEntry.DeployMode == Deployed4)
            {
                // File will also be in solution folder
                string solutionPath = String.Format("{0}/{1}", this.SolutionReleaseDirectory, remoteAsset.FileFullPath);
                if (!File.Exists(solutionPath) || !Enumerable.SequenceEqual(remoteAsset.FileEntry.MD5, Utilities.CalculateMD5(solutionPath)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(solutionPath));
                    File.Copy(deployPath, solutionPath);
                }
            }
        }
        public override bool IsFileInstalled(RemoteAsset remoteAsset)
        {
            string deployPath = GetFileDeployPath(remoteAsset);

            if (!File.Exists(deployPath) || !Enumerable.SequenceEqual(remoteAsset.FileEntry.MD5, Utilities.CalculateMD5(deployPath)))
            {
                return(false);
            }

            if (this.SolutionReleaseDirectory != null && remoteAsset.FileEntry.DeployMode == Deployed4)
            {
                string solutionPath = GetFileSolutionPath(remoteAsset);
                if (!File.Exists(solutionPath) || !Enumerable.SequenceEqual(remoteAsset.FileEntry.MD5, Utilities.CalculateMD5(solutionPath)))
                {
                    return(false);
                }
            }

            return(true);
        }
        public override void InstallFile(RemoteAsset remoteAsset)
        {
            ArchiveVersionDirectory foundDirectory = this.GetArchiveDirectory(remoteAsset.StringVersion);

            bool fileAlreadyDownloaded = false;

            foreach (RAF raf in foundDirectory.Archives)
            {
                RAFFileEntry fileEntry = raf.Files.Find(x => x.Path.Equals(remoteAsset.FileFullPath, StringComparison.InvariantCultureIgnoreCase));
                if (fileEntry != null)
                {
                    try
                    {
                        byte[] fileEntryContent = fileEntry.GetContent(remoteAsset.FileEntry.DeployMode == RAFCompressed);
                        if (Enumerable.SequenceEqual(remoteAsset.FileEntry.MD5, Utilities.CalculateMD5(fileEntryContent)))
                        {
                            fileAlreadyDownloaded = true;
                        }
                    }
                    catch (Exception) { }

                    if (fileAlreadyDownloaded)
                    {
                        break;
                    }
                    else
                    {
                        raf.Files.Remove(fileEntry);
                    }
                }
            }
            if (!fileAlreadyDownloaded)
            {
                foundDirectory.Archives[0].AddFile(remoteAsset.FileFullPath, remoteAsset.AssetContent.GetAssetData(remoteAsset.FileEntry.DeployMode == RAFCompressed), false);
                foundDirectory.Archives[0].Save();
            }
        }
Beispiel #14
0
 private string GetOutputPath(RemoteAsset remoteAsset)
 {
     return(String.Format("{0}/{1}/releases/{2}/files/{3}", InstallationDirectory, ProjectRelease.Name, FileVersionInPath ? remoteAsset.StringVersion : ProjectRelease.Version, remoteAsset.FileFullPath));
 }
Beispiel #15
0
 private string GetFilePath(RemoteAsset remoteAsset)
 {
     return(String.Format("{0}/{1}/{2}", this.ManagedFilesDirectory, remoteAsset.StringVersion, remoteAsset.FileFullPath));
 }
 public abstract bool IsFileInstalled(RemoteAsset remoteAsset);
 public abstract void InstallFile(RemoteAsset remoteAsset);
 private string GetFileSolutionPath(RemoteAsset remoteAsset)
 {
     return(String.Format("{0}/{1}", this.SolutionReleaseDirectory, remoteAsset.FileFullPath));
 }
Beispiel #19
0
        public override bool IsFileInstalled(RemoteAsset remoteAsset)
        {
            string outputPath = GetOutputPath(remoteAsset);

            return(File.Exists(outputPath) && Enumerable.SequenceEqual(remoteAsset.FileEntry.MD5, Utilities.CalculateMD5(outputPath)));
        }
 private string GetFileDeployPath(RemoteAsset remoteAsset)
 {
     return(String.Format("{0}/{1}", this.DeployDirectory, remoteAsset.FileFullPath));
 }