getLocalState :: FilePath -> IO (Set File)
getLocalState syncDirPath = Set.insert (Dir (Path "./")) <$> findFilesRecursive syncDirPath
    where
        relativeToSyncDir = makeRelative syncDirPath
        findFilesRecursive dirPath = do
            properNames <- getDirContents dirPath
            content <- forM properNames $ \name -> do
                let subPath = dirPath </> name
                isDirectory <- doesDirectoryExist subPath
                if isDirectory
                    then findFilesRecursive subPath
                    else Set.singleton <$> getLocalFile syncDirPath subPath
            let contentSet = Set.unions content
            let relativeDirPath = addTrailingPathSeparator (relativeToSyncDir dirPath)
            let dir = Dir $ Path relativeDirPath
            return $ if relativeDirPath == "./" then contentSet else Set.insert dir contentSet
getLocalState :: FilePath -> IO (Set File)
getLocalState syncDirPath = Set.insert (Dir (Path "./")) <$> findFilesRecursive syncDirPath
    where
        relativeToSyncDir = makeRelative syncDirPath
        findFilesRecursive dirPath = do
            properNames <- getDirContents dirPath
            content <- forM properNames $ \name -> do
                let subPath = dirPath </> name
                isDirectory <- doesDirectoryExist subPath
                if isDirectory
                    then findFilesRecursive subPath
                    else Set.singleton <$> getLocalFile syncDirPath subPath
            let contentSet = Set.unions content
            let relativeDirPath = addTrailingPathSeparator (relativeToSyncDir dirPath)
            let dir = Dir $ Path relativeDirPath
            return $ if relativeDirPath == "./" then contentSet else Set.insert dir contentSet
getLocalState syncDirPath = Set.insert (Dir (Path "./")) <$> findFilesRecursive syncDirPath
    where
        relativeToSyncDir = makeRelative syncDirPath
        findFilesRecursive dirPath = do
            properNames <- getDirContents dirPath
            content <- forM properNames $ \name -> do
                let subPath = dirPath </> name
                isDirectory <- doesDirectoryExist subPath
                if isDirectory
                    then findFilesRecursive subPath
                    else Set.singleton <$> getLocalFile syncDirPath subPath
            let contentSet = Set.unions content
            let relativeDirPath = addTrailingPathSeparator (relativeToSyncDir dirPath)
            let dir = Dir $ Path relativeDirPath
            return $ if relativeDirPath == "./" then contentSet else Set.insert dir contentSet