 		self.workspace = workspace
 		self.baseUrl = baseUrl
 		self.saveQueue = DispatchQueue(label: "rc2.filecache.save.serial")
+		self.taskLockQueue = DispatchQueue(label: "rc2.filecache.tasklock")
 		super.init()
 		let myConfig = config
 		if myConfig.httpAdditionalHeaders == nil {

	case unknownError(Error)
}

protocol FileCache {
	var fileManager:Rc2FileManager { get }

	func isFileCached(_ file:File) -> Bool


public final class DefaultFileCache: NSObject, FileCache {
	//MARK: properties
	public var fileManager:Rc2FileManager
	fileprivate var baseUrl: URL
	fileprivate let workspace: Workspace
	fileprivate var urlSession: URLSession?
	fileprivate var tasks:[Int:DownloadTask] = [:] //key is task identifier
	fileprivate var downloadingAllFiles: Bool = false
	///if downloadingAllFiles, the size of all files being downloaded
	fileprivate var totalDownloadSize: Int = 0
