 
     class func downloadAttachmentsOfMessage(message: Message, reportProgress: ProgressReporter.ReportAction?, imageFinished: (UIImage -> Void)?) {
 
+        let downloadState = message.downloadState
+
+        if downloadState == MessageDownloadState.Downloaded.rawValue {
+            return
+        }
+
         let messageID = message.messageID
         let mediaType = message.mediaType
 
         let attachmentURLString = message.attachmentURLString
-        let downloadState = message.downloadState
-
-        if downloadState == MessageDownloadState.Downloaded.rawValue {
-            //reportProgress?(1.0)
-
-            return
-        }
         
         if !attachmentURLString.isEmpty, let URL = NSURL(string: attachmentURLString) {
 

                    break
                }
            }

//            if progressReporter.downloadTasks.filter({ $0 == downloadTask }).count > 0 {
//                progressReporter.progress[].completedUnitCount += bytesWritten
//
//                progressReporter.reportProgressAction?(progressReporter.progress.fractionCompleted)
//
//                println("progressReporter.progress.completedUnitCount: \(progressReporter.progress.completedUnitCount)")
//            }
        }


        //let progress: Double = Double(totalBytesWritten) / Double(totalBytesExpectedToWrite)

        //reportProgress(progress, ofDownloadTask: downloadTask)

        //println("downloadTask progress \(progress)")
    }

//    func URLSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didResumeAtOffset fileOffset: Int64, expectedTotalBytes: Int64) {
//
//        println("fuck")
//        
//        for progressReporter in progressReporters {
//            if progressReporter.downloadTasks.filter({ $0 == downloadTask }).count > 0 {
//                if progressReporter.progress.totalUnitCount == -1 {
//                    progressReporter.progress.totalUnitCount = expectedTotalBytes
//                } else {
//                    progressReporter.progress.totalUnitCount += expectedTotalBytes
//                }
//            }
//
//            println("progressReporter.progress.totalUnitCount: \(progressReporter.progress.totalUnitCount)")
//        }
//    }
}


            }

            var progress = [NSProgress]()
            for _ in downloadTasks {
                progress.append(NSProgress())
            }

            let progressReporter = ProgressReporter(downloadTasks: downloadTasks, finishedActions: [attachmentFinishedAction, thumbnailFinishedAction], progress: progress, reportProgressAction: reportProgress)

            sharedDownloader.progressReporters.append(progressReporter)

            downloadTasks.map { $0.resume() }
        }
    }
}

