Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Commit

Permalink
adds exclusions
Browse files Browse the repository at this point in the history
  • Loading branch information
rducom committed May 7, 2021
1 parent c46c7dc commit 5652ef0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions TCC.Lib/Blocks/BlockHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,23 @@ public static IEnumerable<CompressionBlock> GenerateCompressBlocks(this Compress
filters = compressOption.Filter.ToHashSet(StringComparer.OrdinalIgnoreCase);
}

HashSet<string> excludes = null;
if (compressOption.Exclude != null && compressOption.Exclude.Any())
{
excludes = compressOption.Exclude.ToHashSet(StringComparer.OrdinalIgnoreCase);
}

foreach (var block in blocks)
{
if (filters != null && !filters.Contains(block.BlockName))
{
continue;
}

if (excludes != null && excludes.Contains(block.BlockName))
{
continue;
}
block.DestinationArchiveExtension = extension;
block.FolderProvider = compFolder;
yield return block;
Expand Down
1 change: 1 addition & 0 deletions TCC.Lib/Options/CompressOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class CompressOption : TccOption
public BackupMode? BackupMode { get; set; }
public int? Retry { get; set; }
public IEnumerable<string> Filter { get; set; }
public IEnumerable<string> Exclude { get; set; }
public bool FolderPerDay { get; set; }
public int? BoostRatio { get; set; }
public int? CleanupTime { get; set; }
Expand Down
3 changes: 3 additions & 0 deletions TCC/Parser/CompressCmdOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public class CompressCmdOptions : BaseCmdOptions
[Option("filter", HelpText = "Optional filters")]
public IEnumerable<string> Filter { get; set; }

[Option("exclude", HelpText = "Exclusion filters")]
public IEnumerable<string> Exclude { get; set; }

[Option("folderPerDay", HelpText = "Creates a sub folder per day")]
public bool FolderPerDay { get; set; }

Expand Down
1 change: 1 addition & 0 deletions TCC/Parser/ParseCommandLineHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static TccCommand ParseCommandLine(this string[] args)
BackupMode = opts.BackupMode,
Retry = opts.Retry,
Filter = opts.Filter,
Exclude = opts.Exclude,
SlackChannel = opts.SlackChannel,
SlackSecret = opts.SlackSecret,
BucketName = opts.BucketName,
Expand Down

0 comments on commit 5652ef0

Please sign in to comment.