                     chunk = [NSDictionary]()
                     chunkStartTime = NSDate()
                 }
-//            })
+            })
         })
     }
     

    }
    
    
//    struct CompleteInfo {
//        var fullPath: String
//        var mimeType: String
//    }
//    
//    func getCompleteInfo(_ libraryItem: NSDictionary, completion: @escaping (_ completeInfo: CompleteInfo?) -> Void) {
//        
//        let ident = libraryItem.object(forKey: "id") as! String
//        let fetchResult = PHAsset.fetchAssets(withLocalIdentifiers: [ident], options: self.fetchOptions)
//        if fetchResult.count == 0 {
//            completion(nil)
//            return
//        }
//        
//        let mediaType = libraryItem.object(forKey: "mediaType") as! String
//        fetchResult.enumerateObjects({
//            (obj: AnyObject, idx: Int, stop: UnsafeMutablePointer<ObjCBool>) -> Void in
//            let asset = obj as! PHAsset
//            
//            if(mediaType == "image") {
//                PHImageManager.default().requestImageData(for: asset, options: self.imageRequestOptions) {
//                    (imageData: Data?, dataUTI: String?, orientation: UIImageOrientation, info: [AnyHashable: Any]?) in
//                    
//                    if(imageData == nil) {
//                        completion(nil)
//                    }
//                    else {
//                        let file_url:URL = info!["PHImageFileURLKey"] as! URL
//                        let mime_type = self.mimeTypes[file_url.pathExtension.lowercased()]!
//                        completion(CompleteInfo(fullPath: "cdvfile://" + file_url.relativePath, mimeType: mime_type))
//                    }
//                }
//            }
//            else if(mediaType == "video") {
//                
//                PHImageManager.default().requestAVAsset(forVideo: asset, options: nil, resultHandler: { (avAsset: AVAsset?, avAudioMix: AVAudioMix?, info: [AnyHashable : Any]?) in
//                    
//                    let video_asset = avAsset as! AVURLAsset
//                    let url = URL(fileURLWithPath: video_asset.url.relativePath)
//                    let mime_type = self.mimeTypes[url.pathExtension.lowercased()]!
//                    completion(CompleteInfo(fullPath: "cdvfile://" + url.relativePath, mimeType: mime_type))
//                    
//                })
//            }
//            else if(mediaType == "audio") {
//                // TODO:
//                completion(nil)
//            }
//            else {
//                completion(nil) // unknown
//            }
//        })
//    }
    
    
    private func assetToLibraryItem(asset: PHAsset, useOriginalFileNames: Bool, includeAlbumData: Bool) -> NSMutableDictionary {


            chunk.append(libraryItem)
            
            self.getCompleteInfo(libraryItem, completion: { (fullPath) in
                
                libraryItem["filePath"] = fullPath
            
                if index == fetchResult.count - 1 { // Last item
                    completion(chunk, chunkNum, true)
