@@ -380,6 +380,7 @@ createThunkWithLatest target s = do
380380
381381updateThunkToLatest :: MonadObelisk m => FilePath -> m ()
382382updateThunkToLatest target = withSpinner' ("Updating thunk " <> T.pack target <> " to latest") (pure $ const $ "Thunk " <> T.pack target <> " updated to latest") $ do
383+ checkThunkDirectory "ob thunk update directory cannot be '.'" target
383384 (overwrite, ptr) <- readThunk target >>= \case
384385 Left err -> failWith $ T.pack $ "thunk update: " <> show err
385386 Right c -> case c of
@@ -565,15 +566,14 @@ unpackThunk :: MonadObelisk m => FilePath -> m ()
565566unpackThunk = unpackThunk' False
566567
567568-- | Check that we are not somewhere inside the thunk directory
568−checkThunkDirectory :: MonadObelisk m => FilePath -> m ()
569−checkThunkDirectory thunkDir = do
569+checkThunkDirectory :: MonadObelisk m => Text -> FilePath -> m ()
570+checkThunkDirectory msg thunkDir = do
570571 currentDir <- liftIO getCurrentDirectory
571572 thunkDir' <- liftIO $ canonicalizePath thunkDir
572− when (thunkDir' `L.isInfixOf` currentDir) $
573− failWith "Can't pack/unpack from within the thunk directory"
573+ when (thunkDir' `L.isInfixOf` currentDir) $ failWith msg
574574
575575unpackThunk' :: MonadObelisk m => Bool -> FilePath -> m ()
576−unpackThunk' noTrail thunkDir = checkThunkDirectory thunkDir >> readThunk thunkDir >>= \case
576+unpackThunk' noTrail thunkDir = checkThunkDirectory "Can't pack/unpack from within the thunk directory" thunkDir >> readThunk thunkDir >>= \case
577577 Left err -> failWith $ "thunk unpack: " <> T.pack (show err)
578578 --TODO: Overwrite option that rechecks out thunk; force option to do so even if working directory is dirty
579579 Right (ThunkData_Checkout _) -> failWith "thunk unpack: thunk is already unpacked"
@@ -610,7 +610,7 @@ packThunk :: MonadObelisk m => FilePath -> m ThunkPtr
610610packThunk = packThunk' False
611611
612612packThunk' :: MonadObelisk m => Bool -> FilePath -> m ThunkPtr
613−packThunk' noTrail thunkDir = checkThunkDirectory thunkDir >> readThunk thunkDir >>= \case
613+packThunk' noTrail thunkDir = checkThunkDirectory "Can't pack/unpack from within the thunk directory" thunkDir >> readThunk thunkDir >>= \case
614614 Left err -> failWith $ T.pack $ "thunk pack: " <> show err
615615 Right (ThunkData_Packed _) -> failWith "pack: thunk is already packed"
616616 Right (ThunkData_Checkout _) -> do