Video avatar fixes

This commit is contained in:
Ilya Laktyushin
2020-07-13 04:00:15 +03:00
parent c142520e1d
commit b4fe44ed89
9 changed files with 100 additions and 42 deletions

View File

@@ -266,16 +266,21 @@ public final class MediaBox {
}
}
public func copyResourceData(from: MediaResourceId, to: MediaResourceId) {
public func copyResourceData(from: MediaResourceId, to: MediaResourceId, synchronous: Bool = false) {
if from.isEqual(to: to) {
return
}
self.dataQueue.async {
let begin = {
let pathsFrom = self.storePathsForId(from)
let pathsTo = self.storePathsForId(to)
let _ = try? FileManager.default.copyItem(atPath: pathsFrom.partial, toPath: pathsTo.partial)
let _ = try? FileManager.default.copyItem(atPath: pathsFrom.complete, toPath: pathsTo.complete)
}
if synchronous {
begin()
} else {
self.dataQueue.async(begin)
}
}
private func maybeCopiedPreFetchedResource(completePath: String, resource: MediaResource) {