-- | Delete a job and all its output.
deleteJob :: (TS m, MonadError JobError m) => Job.Name -> m ()
deleteJob name = existing _AJob name >>= \js -> do
    ensureNoActiveDependents name
    removeRevDepsFromDeps js
    ES.deleteJob name
    ES.schedule . CleanupJob name $ js ^. Job.uuid
    scheduleCleanupFiles js

-- | Seal a box to prevent further uploads. Does nothing if the box is already sealed.
deleteJob :: (TS m, MonadError JobError m) => Job.Name -> m ()
deleteJob name = existing _AJob name >>= \js -> do
    ensureNoActiveDependents name
    removeRevDepsFromDeps js
    ES.deleteJob name
    ES.schedule . CleanupJob name $ js ^. Job.uuid
    scheduleCleanupFiles js

-- | Seal a box to prevent further uploads. Does nothing if the box is already sealed.
deleteJob name = existing _AJob name >>= \js -> do
    ensureNoActiveDependents name
    removeRevDepsFromDeps js
    ES.deleteJob name
    ES.schedule . CleanupJob name $ js ^. Job.uuid
    scheduleCleanupFiles js

-- | Seal a box to prevent further uploads. Does nothing if the box is already sealed.