Example #1
0
        public KuduSync(KuduSyncOptions options, Logger logger)
        {
            _logger  = logger;
            _options = options;

            _from             = Path.GetFullPath(options.From);
            _to               = Path.GetFullPath(options.To);
            _nextManifest     = new DeploymentManifest(options.NextManifestFilePath);
            _previousManifest = new HashSet <string>(DeploymentManifest.LoadManifestFile(options.PreviousManifestFilePath).Paths, StringComparer.OrdinalIgnoreCase);
            _ignoreList       = BuildIgnoreList(options.Ignore);
            _whatIf           = options.WhatIf;

            if (!options.IgnoreManifestFile && string.IsNullOrWhiteSpace(options.NextManifestFilePath))
            {
                throw new InvalidOperationException("The 'nextManifest' option must be specified unless the 'ignoremanifest' option is set.");
            }

            if (_whatIf)
            {
                throw new NotSupportedException("WhatIf flag is currently not supported");
            }

            if (FileSystemHelpers.IsSubDirectory(_from, _to) || FileSystemHelpers.IsSubDirectory(_to, _from))
            {
                throw new InvalidOperationException("Source and destination directories cannot be sub-directories of each other");
            }
        }
Example #2
0
        public KuduSync(KuduSyncOptions options, Logger logger, bool saveAppOffline)
        {
            _logger  = logger;
            _options = options;

            _from             = Path.GetFullPath(options.From);
            _to               = Path.GetFullPath(options.To);
            _targetSubFolder  = options.TargetSubFolder;
            _nextManifest     = new DeploymentManifest(options.NextManifestFilePath);
            _previousManifest = new HashSet <string>(DeploymentManifest.LoadManifestFile(options.PreviousManifestFilePath).Paths, StringComparer.OrdinalIgnoreCase);
            BuildIgnoreList(options.Ignore, out _ignoreList, out _wildcardIgnoreList);
            _whatIf = options.WhatIf;
            _toBeDeletedDirectoryPath = Path.Combine(Environment.ExpandEnvironmentVariables(ConfigurationManager.AppSettings["KuduSyncDataDirectory"]), "tobedeleted");
            _saveAppOffline           = saveAppOffline;

            if (!options.IgnoreManifestFile && string.IsNullOrWhiteSpace(options.NextManifestFilePath))
            {
                throw new InvalidOperationException("The 'nextManifest' option must be specified unless the 'ignoremanifest' option is set.");
            }

            if (_whatIf)
            {
                throw new NotSupportedException("WhatIf flag is currently not supported");
            }

            if (FileSystemHelpers.IsSubDirectory(_from, _to) || FileSystemHelpers.IsSubDirectory(_to, _from))
            {
                throw new InvalidOperationException("Source and destination directories cannot be sub-directories of each other");
            }

            if (!TryCleanupToBeDeletedDirectory())
            {
                _logger.Log("Cannot removed the 'to be deleted' directory, ignoring");
            }

            if (!string.IsNullOrEmpty(_targetSubFolder))
            {
                _to = Path.Combine(_to, _targetSubFolder);
            }
        }