Download system temp fix

This commit is contained in:
Chris Li 2016-08-31 11:48:59 -04:00
parent 828577d634
commit 2d96977377
5 changed files with 13 additions and 10 deletions

View File

@ -28,11 +28,14 @@ class DownloadTasksController: UIViewController, UITableViewDelegate, UITableVie
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
tableView.emptyDataSetSource = self
tableView.emptyDataSetDelegate = self
tableView.delegate = self tableView.delegate = self
tableView.dataSource = self tableView.dataSource = self
tableView.tableFooterView = UIView() tableView.tableFooterView = UIView()
tableView.estimatedRowHeight = 90.0
tableView.rowHeight = UITableViewAutomaticDimension
tableView.emptyDataSetSource = self
tableView.emptyDataSetDelegate = self
} }
override func viewWillAppear(animated: Bool) { override func viewWillAppear(animated: Bool) {

View File

@ -49,7 +49,7 @@
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.7.1637</string> <string>1.7.1643</string>
<key>ITSAppUsesNonExemptEncryption</key> <key>ITSAppUsesNonExemptEncryption</key>
<false/> <false/>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>

View File

@ -11,7 +11,6 @@
<!--Cloud--> <!--Cloud-->
<scene sceneID="x2g-Rm-HUS"> <scene sceneID="x2g-Rm-HUS">
<objects> <objects>
<placeholder placeholderIdentifier="IBFirstResponder" id="TMf-0g-nhn" userLabel="First Responder" sceneMemberID="firstResponder"/>
<tableViewController id="NBP-9l-DA2" customClass="CloudBooksController" customModule="Kiwix" customModuleProvider="target" sceneMemberID="viewController"> <tableViewController id="NBP-9l-DA2" customClass="CloudBooksController" customModule="Kiwix" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="sit-w1-Gpr"> <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="sit-w1-Gpr">
<rect key="frame" x="0.0" y="64" width="375" height="603"/> <rect key="frame" x="0.0" y="64" width="375" height="603"/>
@ -112,6 +111,7 @@
<tabBarItem key="tabBarItem" title="Cloud" id="f2P-kQ-k9n"/> <tabBarItem key="tabBarItem" title="Cloud" id="f2P-kQ-k9n"/>
<navigationItem key="navigationItem" id="JNh-sG-ihV"/> <navigationItem key="navigationItem" id="JNh-sG-ihV"/>
</tableViewController> </tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="TMf-0g-nhn" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="-143" y="-2082"/> <point key="canvasLocation" x="-143" y="-2082"/>
</scene> </scene>
@ -388,7 +388,7 @@
<constraint firstItem="6Zg-Xf-xgS" firstAttribute="leading" secondItem="Hji-3G-yaJ" secondAttribute="trailing" constant="2" id="5lO-Sp-t2G"/> <constraint firstItem="6Zg-Xf-xgS" firstAttribute="leading" secondItem="Hji-3G-yaJ" secondAttribute="trailing" constant="2" id="5lO-Sp-t2G"/>
<constraint firstItem="v8H-ZV-HNV" firstAttribute="leading" secondItem="oM4-Hy-Mkf" secondAttribute="leadingMargin" id="7FW-0t-ljT"/> <constraint firstItem="v8H-ZV-HNV" firstAttribute="leading" secondItem="oM4-Hy-Mkf" secondAttribute="leadingMargin" id="7FW-0t-ljT"/>
<constraint firstAttribute="leadingMargin" secondItem="Too-68-SzG" secondAttribute="leading" constant="-2" id="9Vd-3e-m5f"/> <constraint firstAttribute="leadingMargin" secondItem="Too-68-SzG" secondAttribute="leading" constant="-2" id="9Vd-3e-m5f"/>
<constraint firstAttribute="bottomMargin" secondItem="v8H-ZV-HNV" secondAttribute="bottom" constant="-8" id="9ac-Vl-xk9"/> <constraint firstAttribute="bottomMargin" secondItem="v8H-ZV-HNV" secondAttribute="bottom" id="9ac-Vl-xk9"/>
<constraint firstAttribute="trailingMargin" secondItem="6Zg-Xf-xgS" secondAttribute="trailing" id="D9Q-Dz-SXA"/> <constraint firstAttribute="trailingMargin" secondItem="6Zg-Xf-xgS" secondAttribute="trailing" id="D9Q-Dz-SXA"/>
<constraint firstItem="g0o-rT-qxm" firstAttribute="top" secondItem="Too-68-SzG" secondAttribute="bottom" constant="4" id="IJR-yJ-4xs"/> <constraint firstItem="g0o-rT-qxm" firstAttribute="top" secondItem="Too-68-SzG" secondAttribute="bottom" constant="4" id="IJR-yJ-4xs"/>
<constraint firstItem="g0o-rT-qxm" firstAttribute="trailing" secondItem="oM4-Hy-Mkf" secondAttribute="trailingMargin" id="OFh-b3-2bf"/> <constraint firstItem="g0o-rT-qxm" firstAttribute="trailing" secondItem="oM4-Hy-Mkf" secondAttribute="trailingMargin" id="OFh-b3-2bf"/>
@ -714,6 +714,6 @@
</scene> </scene>
</scenes> </scenes>
<inferredMetricsTieBreakers> <inferredMetricsTieBreakers>
<segue reference="hUB-db-MDL"/> <segue reference="eUy-Zq-fkw"/>
</inferredMetricsTieBreakers> </inferredMetricsTieBreakers>
</document> </document>

View File

@ -21,7 +21,7 @@
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.7.2076</string> <string>1.7.2083</string>
<key>NSExtension</key> <key>NSExtension</key>
<dict> <dict>
<key>NSExtensionMainStoryboard</key> <key>NSExtensionMainStoryboard</key>

View File

@ -52,11 +52,11 @@ class Network: NSObject, NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSe
func URLSession(session: NSURLSession, task: NSURLSessionTask, didCompleteWithError error: NSError?) { func URLSession(session: NSURLSession, task: NSURLSessionTask, didCompleteWithError error: NSError?) {
guard let error = error, let bookID = task.taskDescription else {return} guard let error = error, let bookID = task.taskDescription else {return}
self.context.performBlockAndWait { self.context.performBlockAndWait {
guard let book = Book.fetch(bookID, context: self.context) else {return} guard let book = Book.fetch(bookID, context: self.context),
let downloadTask = book.downloadTask else {return}
if error.code == NSURLErrorCancelled { if error.code == NSURLErrorCancelled {
// If download task doesnt exist, it must mean download is cancelled by user // If download task doesnt exist, it must mean download is cancelled by user
// DownloadTask object will have been deleted when user tap Cancel button / table row action // DownloadTask object will have been deleted when user tap Cancel button / table row action
guard let downloadTask = book.downloadTask else {return}
downloadTask.totalBytesWritten = task.countOfBytesReceived downloadTask.totalBytesWritten = task.countOfBytesReceived
downloadTask.state = .Paused downloadTask.state = .Paused
@ -64,7 +64,7 @@ class Network: NSObject, NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSe
guard let resumeData = error.userInfo[NSURLSessionDownloadTaskResumeData] as? NSData else {return} guard let resumeData = error.userInfo[NSURLSessionDownloadTaskResumeData] as? NSData else {return}
Preference.resumeData[bookID] = resumeData Preference.resumeData[bookID] = resumeData
} else { } else {
// Handle other errors downloadTask.state = .Error
} }
} }
} }