From d836cb37f108b2af047703730c59c73a40ea4627 Mon Sep 17 00:00:00 2001 From: Alin Date: Mon, 18 Nov 2024 09:44:36 -0700 Subject: [PATCH] Update Folders.swift --- Pearcleaner/Settings/Folders.swift | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Pearcleaner/Settings/Folders.swift b/Pearcleaner/Settings/Folders.swift index 8b1d7c2..107a252 100644 --- a/Pearcleaner/Settings/Folders.swift +++ b/Pearcleaner/Settings/Folders.swift @@ -80,13 +80,18 @@ struct FolderSettingsTab: View { providers.forEach { provider in provider.loadDataRepresentation(forTypeIdentifier: "public.file-url") { (data, error) in guard let data = data, error == nil, - let url = URL(dataRepresentation: data, relativeTo: nil), - url.hasDirectoryPath else { - printOS("FSM: Failed to load URL or the item is not a folder") + let url = URL(dataRepresentation: data, relativeTo: nil) else { + printOS("FSM: Failed to load URL") return } - updateOnMain { - fsm.addPath(url.path) + + var isDirectory: ObjCBool = false + if FileManager.default.fileExists(atPath: url.path, isDirectory: &isDirectory), isDirectory.boolValue { + updateOnMain { + fsm.addPath(url.path) + } + } else { + printOS("FSM: The URL is not a directory: \(url.path)") } } }