From a75fce8dfa30e86a9b61c175ca1db04e49fcb77f Mon Sep 17 00:00:00 2001 From: Alexander Bondarenko <486682+dpwiz@users.noreply.github.com> Date: Wed, 15 Nov 2023 17:57:29 +0200 Subject: [PATCH] Fix hostStore path and check before removing (#3375) --- src/Simplex/Chat/Remote.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Simplex/Chat/Remote.hs b/src/Simplex/Chat/Remote.hs index 16044ee923..b3d2d0ebf0 100644 --- a/src/Simplex/Chat/Remote.hs +++ b/src/Simplex/Chat/Remote.hs @@ -70,7 +70,7 @@ import Simplex.RemoteControl.Types import System.FilePath (takeFileName, ()) import UnliftIO import UnliftIO.Concurrent (forkIO) -import UnliftIO.Directory (copyFile, createDirectoryIfMissing, removeDirectoryRecursive, renameFile) +import UnliftIO.Directory (copyFile, createDirectoryIfMissing, doesDirectoryExist, removeDirectoryRecursive, renameFile) -- when acting as host minRemoteCtrlVersion :: AppVersion @@ -279,11 +279,11 @@ remoteHostInfo RemoteHost {remoteHostId, storePath, hostDeviceName} sessionState deleteRemoteHost :: ChatMonad m => RemoteHostId -> m () deleteRemoteHost rhId = do RemoteHost {storePath} <- withStore (`getRemoteHost` rhId) - chatReadVar filesFolder >>= \case + chatReadVar remoteHostsFolder >>= \case Just baseDir -> do let hostStore = baseDir storePath logInfo $ "removing host store at " <> tshow hostStore - removeDirectoryRecursive $ hostStore + whenM (doesDirectoryExist hostStore) $ removeDirectoryRecursive hostStore Nothing -> logWarn "Local file store not available while deleting remote host" withStore' (`deleteRemoteHostRecord` rhId)