Ejemplo n.º 1
0
        public void DeployPackages()
        {
            //Validate configuration
            if (!_localFileService.DirectoryExists(_configurationProvider.RootSearchPath))
            {
                _logger.Error($"Desired search path {_configurationProvider.RootSearchPath} not found");
                return;
            }
            if (!_localFileService.DirectoryExists(_configurationProvider.DeployToPath))
            {
                _logger.Error($"Desired search path {_configurationProvider.DeployToPath} not found");
                return;
            }

            //Remove older files
            _logger.Debug("Removing install files from deploy path");
            _localFileService.DeleteFiles(_configurationProvider.DeployToPath, "*_install.zip");

            //Get the new files
            var toDeploy = _installationPackageLocatorService.FindLatestVersionPackages(_configurationProvider.RootSearchPath);

            _logger.Debug($"{toDeploy.Count} files found to deploy");

            //Copy files
            _localFileService.CopyFiles(toDeploy, _configurationProvider.DeployToPath);
            _logger.Debug("Finished deploy process");
        }
        public void DirectoryExistsShouldReturnFalseIfDirectoryDoesNotExist()
        {
            //Arrange
            var directoryPath = "Test";

            //Act
            var result = _fileService.DirectoryExists(directoryPath);

            //Assert
            Assert.IsFalse(result);
        }
        public void CleanupLogFiles(SiteCleanupConfiguration siteInfo)
        {
            _log.Debug($"Starting clean of {siteInfo.SiteName}");
            if (siteInfo.LogHistoryDaysToKeep < 2)
            {
                _log.Error("Unable to process, must keep at least 2 days of logs");
                return;
            }

            var directoryExists = _localFileService.DirectoryExists(siteInfo.DnnRootDirectoryPath);

            if (!directoryExists)
            {
                _log.Error("Provided directory not fount, no further processing for this site");
                return;
            }

            //Verify that it is a DNN install
            var dnnLogPath   = _localFileService.BuildDnnLogFolderPath(siteInfo.DnnRootDirectoryPath);
            var dnnLogExists = _localFileService.DirectoryExists(dnnLogPath);

            if (!dnnLogExists)
            {
                _log.Error($"Unable to find DNN log folder.  Looked in '{dnnLogPath}'");
                return;
            }

            //Get the list of log files
            _log.Debug($"Searching for files in {dnnLogPath}");
            var logFiles = _localFileService.FindFiles(dnnLogPath, "*.log.resources");

            if (logFiles.Count > siteInfo.LogHistoryDaysToKeep)
            {
                //Get the to delete files
                var toDelete = logFiles.OrderByDescending(lf => lf.CreationTimeUtc).Skip(siteInfo.LogHistoryDaysToKeep);
                foreach (var fileToDelete in toDelete)
                {
                    _log.Debug($"Deleting {fileToDelete.FullName}");
                    _localFileService.DeleteFile(fileToDelete.FullName);
                }
            }
            else
            {
                _log.Debug(
                    $"Found {logFiles.Count} files and log rules allow for up to {siteInfo.LogHistoryDaysToKeep} no action taken");
            }
        }