         // Have we already downloaded the item?
         let filename = downloadedItems[portalItem.identifier] ?? portalItem.filename
         let tempURL = destinationURLProvider.makeURL(filename: filename)
-        let pathURL = tempURL.pathExtension == "zip" ? tempURL.deletingPathExtension() : tempURL
+        let fileURL = tempURL.pathExtension == "zip" ? tempURL.deletingPathExtension() : tempURL
         
-        // Check if a single file or a folder exists.
-        var isDirectory = ObjCBool(false)
-        let isFileExist = FileManager.default.fileExists(atPath: pathURL.path, isDirectory: &isDirectory)
-        
-        if isFileExist && isDirectory.boolValue {
-            print("Item \(portalItem.identifier) has already been downloaded, and is extracted to an folder")
-            downloadedItems[portalItem.identifier] = filename
-        } else if isFileExist {
+        // Check if a single file or a directory exists.
+        if FileManager.default.fileExists(atPath: fileURL.path) {
             print("Item \(portalItem.identifier) has already been downloaded")
             // This is a temporary measure for users who currently don't have a downloaded items file.
             downloadedItems[portalItem.identifier] = filename

    }
}

/// Creates a URL such as `{portalURL}/sharing/rest/content/items/{itemIdentifier}/data`
/// for the given item in the given portal.
///
/// - Parameters:

    let downloadDirectory: URL
    let fileTypes: [String: [String]]
    
    /// Make a full path for a file based on the mapping between its filename
    /// and file type.
    ///
    /// - Parameter filename: The filename of the file.
    /// - Returns: A URL to the file.
    func makeURL(filename: String) -> URL {
        var url = downloadDirectory
        if let subdirectory = fileTypes.first(where: {
            $0.value.contains((filename as NSString).pathExtension) })?.key {
            url.appendPathComponent(subdirectory, isDirectory: true)
        }
        url.appendPathComponent(filename, isDirectory: false)
