     let downloadDirectory: URL
     let fileTypes: [String: [String]]
     
-    /// Make a full path for a file based on the mapping between its filename and file type.
+    /// 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 {
+        if let subdirectory = fileTypes.first(where: {
+            $0.value.contains((filename as NSString).pathExtension) })?.key {
             url.appendPathComponent(subdirectory, isDirectory: true)
         }
         url.appendPathComponent(filename, isDirectory: false)

        // 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
        
        // 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 {
            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

///
/// - Parameters:
///   - sourceURL: The portal URL to the resource.
///   - destinationURLProvider: A helper struct to make destination URL with filename.
///   - completion: A closure to handle the results.
func downloadFile(at sourceURL: URL, destinationURLProvider: URLProvider, completion: @escaping (Result<URL, Error>) -> Void) {
    let downloadTask = URLSession.shared.downloadTask(with: sourceURL) { (temporaryURL, response, error) in
