Documentation / Rules and scope

Rules and scope

Scope says where Coldpack looks. Rules say what it does with what it finds. Both are edited in Settings, and both are plain data in settings.json.

The order of decisions for one path: built-in excludes, include roots, your rules, safety checks.

Scope: the folders you watch

The Scope tab lists the folders Coldpack watches and scans. Add a folder, remove one, or press Reset to Defaults. The last folder cannot be removed. When you change the list, Coldpack restarts the watcher and scans only the new folders. Folders that leave the scope are not touched again, and files that are already compressed stay compressed.

The Scope tab with the list of watched folders and the read-only list of built-in excludes

Below the list, the tab shows the built-in excludes, read-only. They always apply: no rule or setting can lift them. See Safety and recovery for the full list.

Rules: one sentence each

A rule is a condition and an action. Rules are checked from top to bottom. The first rule that matches decides, and later rules are not read. If no rule matches, the last line applies: Otherwise, compress with the General values.

The Rules tab: six rules, each shown as one readable sentence
PartChoices
ConditionsPath matches a pattern (glob), extension is one of a list, size at least or at most a value, executable or not. A rule matches when all its conditions hold. A rule with no condition matches every file.
Action skipNever compress. The file stays out of the hot set and out of the scan.
Action compressCompress, and optionally use its own cooldown, minimum age or minimum saving for these files.

Press Add Rule to create one. A new rule is a compress rule with no condition, never a skip rule. Drag a rule to change its order. The editor works on a copy and saves when you press Done, because a change to the rule list makes Coldpack walk the folders again.

The rule editor popover for one rule
A rule never removes a safety check. Open files, clones, hard links and verification apply to every file, whatever a compress rule says.

"Never compress this folder"

A skip rule that names only a path is the cheap way to exclude a folder. When no compress rule stands above it, Coldpack never enters that folder during the scan, drops its file events, and keeps it out of the Finder badge scope and the cleanup suggestions. No rule is evaluated per file below it.

Pattern syntax

Patterns are matched against the absolute path (symbolic links are not resolved), and they are case-sensitive.

PatternMeaning
*Any run of characters except /.
?One character except /.
[abc] [a-z] [!abc]One character of a set, a range, or not in the set.
\Escapes the next character.
** as a whole segmentZero or more folders. x/** matches x and everything below. **/node_modules/** matches a node_modules folder at any depth.
*.sqliteA pattern with no / matches the last name only, at any depth.
~/Downloads/**A pattern with a / matches the whole path. It must start with /, ~/ or **/.

A pattern matches a path when it matches the path or any parent folder of it, so excluding a folder excludes everything below it. A plain path with no wildcard (~/Virtual Machines) matches whole folder names: /a/b covers /a/b/c but not /a/bc. A leading ~/ is your home folder.

An extension in a rule is case-insensitive, with or without the dot, and matches the end of the file name. tar.gz works, and gz also matches a.tar.gz.

Examples

{ "action": "skip", "glob": "~/Virtual Machines" }
{ "action": "skip", "glob": "**/node_modules/**" }
{ "action": "skip", "extensions": ["vmdk", "vdi", "qcow2", "dmg"] }
{ "action": "compress", "glob": "**/Library/Logs/**", "cooldownHours": 1, "minAgeDays": 1 }
{ "action": "compress", "glob": "~/Downloads/**", "minSizeKiB": 102400,
  "minAgeDays": 30, "ratioThreshold": 0.95 }

Ask why: coldpack explain

Give it any path. It names, in decision order, the built-in exclude or the missing include folder that stops the path, or else the rule that decides (its number, action and conditions), and the cooldown, minimum age and ratio in force, each marked rule or default. It is read-only and needs no journal.

coldpack explain ~/Projects/app/node_modules/left-pad/index.js

Defaults that are rules

Two sets of default rules are skip rules that you can see and remove:

Only files you can rewrite

The scan and the event filter keep a file only if you own it, it has no flag beyond hidden and no-dump, and you can write it. Files that belong to root, in a folder you can write (for example the apps of a package manager), never reach the queue and never count in the estimate.