 				//download already in progress. no need to erase
 				return
 			}
+			if let mtime = self.lastModTimes[file.fileId] {
+				let timediff = Date.timeIntervalSinceReferenceDate - mtime
+				if timediff < 0.5 {
+					os_log("skipping flush because too recent", log: .cache, type: .info)
+					return
+				}
+			}
+			os_log("flushing file %d", log: .cache, type: .info, file.fileId)
 			self.removeFile(fileUrl: self.cachedUrl(file: file))
 		}
 	}

	fileprivate let saveQueue: DispatchQueue
	fileprivate let taskLockQueue: DispatchQueue
	fileprivate var downloadAll: DownloadAll?
	
	lazy var fileCacheUrl: URL = { () -> URL in
		var fileDir: URL? = nil

	///   - observer: observer to signal data/completed or error
	private func loadContents(file: File, observer: Signal<Data, Rc2Error>.Observer) {
		let fileUrl = cachedUrl(file: file)
		//for some unknown reason the cached file could be empty and cause a crash
		guard fileUrl.fileExists() && fileUrl.fileSize() > 0 else {
			self.recache(file: file).startWithResult { result in
				guard result.error == nil else {
					observer.send(error: result.error!)
