private void CloneRepository(string repositoryUrl, string gitDirectory, AuthenticationInfo auth) { using (log.IndentLog($"Cloning repository from url '{repositoryUrl}'")) { var returnedPath = repository.Clone(repositoryUrl, gitDirectory, auth); log.Info($"Returned path after repository clone: {returnedPath}"); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure( IApplicationBuilder app, IWebHostEnvironment environment, IServiceProvider serviceProvider, ILoggerFactory loggerFactory, IGitRepository gitRepository, IVersionService versionService, IConfiguration configuration) { var logsPath = configuration["LogsLocalPath"]; if (!Directory.Exists(logsPath)) { Directory.CreateDirectory(logsPath); } loggerFactory.AddFile(logsPath + "/hysite-{Date}.log"); var logger = loggerFactory.CreateLogger("startup"); var version = versionService.GetCurrentGitSHA(); logger.LogWarning($"git commit: {version}"); if (environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); } var postsPath = configuration["PostsLocalPath"]; var configParsed = bool.TryParse(configuration["loadFromGit"], out bool loadFromGit); if (configParsed && loadFromGit) { if (Directory.Exists(postsPath)) { Directory.Delete(postsPath, recursive: true); } gitRepository.Clone(); } var postsFullPath = Path.Combine(Directory.GetCurrentDirectory(), postsPath); var imagesFullPth = Path.Combine(postsFullPath, "img"); if (!Directory.Exists(postsFullPath)) { Directory.CreateDirectory(postsFullPath); } if (!Directory.Exists(imagesFullPth)) { Directory.CreateDirectory(imagesFullPth); } app.UseStaticFiles(); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(postsFullPath), RequestPath = new PathString("") }); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(imagesFullPth), RequestPath = new PathString("") }); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(postsFullPath), RequestPath = new PathString("/.well-known/pki-validation") //@todo: this is for https cert validation, probably can be removed später? }); app.UseRouting(); app.UseHttpsRedirection(); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}" ); }); var fileParser = serviceProvider.GetService <IFileParserService>(); fileParser.ParseExistingFiles(); }