mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-26 23:36:08 +03:00
Reactor slightly
This commit is contained in:
parent
35472e3d26
commit
207afdb84d
@ -133,15 +133,6 @@ class FileService {
|
||||
context: NSManagedObjectContext,
|
||||
callback: ([ScoredUrl]) -> ()
|
||||
) {
|
||||
let saveAndReset = { (context: NSManagedObjectContext) in
|
||||
do {
|
||||
try context.save()
|
||||
} catch {
|
||||
self.log.error("There was an error saving the context: \(error)")
|
||||
}
|
||||
context.reset()
|
||||
}
|
||||
|
||||
var saveCounter = 1
|
||||
var counter = 1
|
||||
|
||||
@ -154,7 +145,7 @@ class FileService {
|
||||
var batons = initialBatons
|
||||
var stack = [(initialBaton, folder)]
|
||||
while let iterElement = stack.popLast() {
|
||||
if self.shouldStop({ saveAndReset(context) }) { return }
|
||||
if self.shouldStop({ self.saveAndReset(context: context) }) { return }
|
||||
|
||||
autoreleasepool {
|
||||
let baton = iterElement.0
|
||||
@ -194,7 +185,7 @@ class FileService {
|
||||
context: context,
|
||||
callback: callback
|
||||
)
|
||||
saveAndReset(context)
|
||||
self.saveAndReset(context: context)
|
||||
|
||||
saveCounter = 0
|
||||
|
||||
@ -212,11 +203,20 @@ class FileService {
|
||||
|
||||
self.log.debug("Flushing and scoring last \(saveCounter) Files")
|
||||
self.scoreAllRegisteredFiles(matcherPool: matcherPool, context: context, callback: callback)
|
||||
saveAndReset(context)
|
||||
self.saveAndReset(context: context)
|
||||
|
||||
self.log.debug("Stored \(counter) Files")
|
||||
}
|
||||
|
||||
private func saveAndReset(context: NSManagedObjectContext) {
|
||||
do {
|
||||
try context.save()
|
||||
} catch {
|
||||
self.log.error("There was an error saving the context: \(error)")
|
||||
}
|
||||
context.reset()
|
||||
}
|
||||
|
||||
private func shouldStop(_ body: (() -> Void)? = nil) -> Bool {
|
||||
self.stopLock.lock()
|
||||
defer { self.stopLock.unlock() }
|
||||
|
@ -59,6 +59,7 @@ class OpenQuicklyWindow: NSObject,
|
||||
private let progressIndicator = NSProgressIndicator(forAutoLayout: ())
|
||||
private let cwdControl = NSPathControl(forAutoLayout: ())
|
||||
private let fileView = NSTableView.standardTableView()
|
||||
private let vcsIgnoreCheckbox = NSButton(forAutoLayout: ())
|
||||
|
||||
private let log = OSLog(subsystem: Defs.loggerSubsystem,
|
||||
category: Defs.LoggerCategory.uiComponents)
|
||||
|
Loading…
Reference in New Issue
Block a user