diff --git a/fn/ns.php b/fn/ns.php index eeb7547..f521e7a 100644 --- a/fn/ns.php +++ b/fn/ns.php @@ -58,18 +58,14 @@ function nsCheckZonePossession($zone) { } function nsDeleteZone($zone) { - // Remove from Knot configuration - knotcConfExec(["unset 'zone[$zone]'"]); - - // Remove Knot zone file - if (unlink(CONF['ns']['knot_zones_path'] . '/' . $zone . 'zone') !== true) - output(500, 'Failed to remove Knot zone file.'); - - // Remove Knot related data + // Delete zone data exec(CONF['dns']['knotc_path'] . ' --force zone-purge ' . $zone, result_code: $code); if ($code !== 0) output(500, 'Failed to purge zone data.'); + // Remove from Knot configuration + knotcConfExec(["unset 'zone[$zone]'"]); + // Remove from database query('delete', 'zones', [ 'zone' => $zone,