This commit is contained in:
2026-08-18 18:11:28 -04:00
parent 0e9a650fa2
commit bbaf47028f
259 changed files with 0 additions and 0 deletions
@@ -0,0 +1,22 @@
/**
* Lexicographic replication priority tiers (boot-critical paths first).
* @param {string[]} paths
*/
export function prioritizeReplicationPaths(paths) {
const boot = ['/boot/', '/etc/bare-os/', '/lib/bare-os/', '/bin/']
/** @type {{ path: string, tier: number }[]} */
const scored = []
for (const p of paths) {
const path = String(p || '').replace(/\\/g, '/')
let tier = 99
for (let i = 0; i < boot.length; i++) {
if (path.startsWith(boot[i])) {
tier = i
break
}
}
scored.push({ path, tier })
}
scored.sort((a, b) => a.tier - b.tier || a.path.localeCompare(b.path))
return scored.map((s) => s.path)
}