public async Task SyncGitLocalRepositoryDirToWebRootDirAsync(string gitLocalRootDir, string webLocalRootDir, CancellationToken cancel = default) { string gitCommitId = await Lfs.GetCurrentGitCommitIdAsync(gitLocalRootDir, cancel); var param = new CopyDirectoryParams( CopyDirectoryFlags.AsyncCopy | CopyDirectoryFlags.Overwrite | CopyDirectoryFlags.Recursive | CopyDirectoryFlags.DeleteNotExistDirs | CopyDirectoryFlags.DeleteNotExistFiles | CopyDirectoryFlags.SilenceSuccessfulReport, FileFlags.WriteOnlyIfChanged, new FileMetadataCopier(FileMetadataCopyMode.TimeAll), new FileMetadataCopier(FileMetadataCopyMode.TimeAll), determineToCopyCallback: (d, e) => { if (e.IsFile && e.Name._IsSamei(Consts.FileNames.GitLabMainte_PublishFileName)) { return(false); } if (e.IsDirectory && e.Name._IsSamei(".git")) { return(false); } return(true); }, determineToDeleteCallback: (e) => { if (e.IsFile && e.Name._IsSamei(Consts.FileNames.GitLabMainte_CommitIdFileName)) { return(false); } if (e.IsFile && e.Name._IsSamei(Consts.FileNames.LogBrowserSecureJson)) { return(false); } if (e.IsDirectory && e.Name._IsSamei(Consts.FileNames.LogBrowserAccessLogDirName)) { return(false); } return(true); } ); string publishPath = gitLocalRootDir._CombinePath(Consts.FileNames.GitLabMainte_PublishFileName); await Lfs.CopyDirAsync(gitLocalRootDir, webLocalRootDir, param : param, cancel : cancel); await Lfs.WriteStringToFileAsync(webLocalRootDir._CombinePath(Consts.FileNames.GitLabMainte_CommitIdFileName), gitCommitId + "\n", FileFlags.WriteOnlyIfChanged, cancel : cancel); PublishConfigData?config = await Lfs.ReadJsonFromFileAsync <PublishConfigData>(publishPath, cancel : cancel, nullIfError : true); if (config == null) { if (await Lfs.IsFileExistsAsync(publishPath)) { config = new PublishConfigData(); } } string secureJsonPath = webLocalRootDir._CombinePath(Consts.FileNames.LogBrowserSecureJson); if (config == null) { try { await Lfs.DeleteFileAsync(secureJsonPath, cancel : cancel); } catch (Exception ex) { ex._Error(); } } else { bool requireAuth = config.Username._IsFilled() && config.Password._IsFilled(); LogBrowserSecureJson sj = new LogBrowserSecureJson(); sj.AuthRequired = requireAuth; if (requireAuth) { sj.AuthDatabase = new KeyValueList <string, string>(); sj.AuthDatabase.Add(config.Username, config.Password); sj.AuthSubDirName = "auth"; } sj.DisableAccessLog = false; sj.AllowZipDownload = true; await Lfs.WriteJsonToFileAsync(secureJsonPath, sj, FileFlags.WriteOnlyIfChanged, cancel : cancel); } }