This commit is contained in:
Chris Li 2016-11-08 17:35:58 -05:00
parent 59f6ddf88c
commit 4f8c74c810
6 changed files with 19 additions and 33 deletions

View File

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

View File

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

View File

@ -33,21 +33,5 @@
endingLineNumber = "37">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Kiwix/CoreData/CoreDataContainer.swift"
timestampString = "500310814.395924"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "14"
endingLineNumber = "14"
landmarkName = "init()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

View File

@ -86,7 +86,7 @@ class Book: NSManagedObject {
// MARK: - Fetch
class func fetchAll(in context: NSManagedObjectContext) -> [Book] {
let request: NSFetchRequest<Book> = Book.fetchRequest() as! NSFetchRequest<Book>
let request: NSFetchRequest<Book> = NSFetchRequest<Book>(entityName: "Book")
return (try? context.fetch(request)) ?? [Book]()
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="11756" systemVersion="16B2555" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="1.8">
<entity name="Article" representedClassName="Article">
<entity name="Article" representedClassName=".Article">
<attribute name="bookmarkDate" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="isBookmarked" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="isMainPage" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
@ -15,7 +15,7 @@
<relationship name="tags" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Tag" inverseName="articles" inverseEntity="Tag" syncable="YES"/>
<userInfo/>
</entity>
<entity name="Book" representedClassName="Book">
<entity name="Book" representedClassName=".Book">
<attribute name="articleCount" optional="YES" attributeType="Integer 64" minValueString="0" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="creator" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="date" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
@ -50,7 +50,7 @@
</uniquenessConstraints>
<userInfo/>
</entity>
<entity name="DownloadTask" representedClassName="DownloadTask" syncable="YES">
<entity name="DownloadTask" representedClassName=".DownloadTask" syncable="YES">
<attribute name="creationTime" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="stateRaw" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="totalBytesWritten" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
@ -61,7 +61,7 @@
</uniquenessConstraint>
</uniquenessConstraints>
</entity>
<entity name="Language" representedClassName="Language" syncable="YES">
<entity name="Language" representedClassName=".Language" syncable="YES">
<attribute name="code" attributeType="String" syncable="YES"/>
<attribute name="isDisplayed" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
@ -77,7 +77,7 @@
</uniquenessConstraint>
</uniquenessConstraints>
</entity>
<entity name="Tag" representedClassName="Tag" syncable="YES">
<entity name="Tag" representedClassName=".Tag" syncable="YES">
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="articles" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Article" inverseName="tags" inverseEntity="Article" syncable="YES"/>
</entity>

View File

@ -21,7 +21,6 @@ class RefreshLibraryOperation: GroupProcedure {
}
fileprivate class Retrieve: NetworkDataProcedure<URLSession> {
init() {
let session = URLSession.shared
let url = URL(string: "https://download.kiwix.org/library/library.xml")!
@ -59,6 +58,16 @@ fileprivate class Process: Procedure, ResultInjection, XMLParserDelegate {
parser.delegate = self
parser.parse()
let toBeDeleted = storeBookIDs.subtracting(memoryBookIDs)
hasUpdate = toBeDeleted.count > 0
context.performAndWait {
toBeDeleted.forEach({ (id) in
})
}
print("\(memoryBookIDs.count)")
if context.hasChanges { try? context.save() }
finish()
}
@ -71,13 +80,6 @@ fileprivate class Process: Procedure, ResultInjection, XMLParserDelegate {
_ = Book.add(meta: attributeDict, in: self.context)
})
}
}
func parserDidEndDocument(_ parser: XMLParser) {
}
func parser(_ parser: XMLParser, parseErrorOccurred parseError: Error) {
memoryBookIDs.insert(id)
}
}