This commit is contained in:
Ali 2023-09-18 19:46:56 +02:00
parent a254de2731
commit b041ba84a9
3 changed files with 24 additions and 4 deletions

View file

@ -57,6 +57,7 @@ private enum MultipartFetchDownloadError {
case revalidateMediaReference
case hashesMissing
case fatal
case webfileNotAvailable
}
private enum MultipartFetchGenericLocationResult {
@ -351,6 +352,8 @@ private enum MultipartFetchSource {
|> mapError { error -> MultipartFetchDownloadError in
if error.errorDescription.hasPrefix("FILEREF_INVALID") || error.errorDescription.hasPrefix("FILE_REFERENCE_") {
return .revalidateMediaReference
} else if error.errorDescription == "WEBFILE_NOT_AVAILABLE" {
return .webfileNotAvailable
}
return .generic
}
@ -379,6 +382,9 @@ private enum MultipartFetchSource {
case let .web(_, location):
return download.request(Api.functions.upload.getWebFile(location: location, offset: Int32(offset), limit: Int32(limit)), tag: tag, continueInBackground: continueInBackground, expectedResponseSize: Int32(limit))
|> mapError { error -> MultipartFetchDownloadError in
if error.errorDescription == "WEBFILE_NOT_AVAILABLE" {
return .webfileNotAvailable
}
return .fatal
}
|> mapToSignal { result, info -> Signal<(Data, NetworkResponseInfo), MultipartFetchDownloadError> in
@ -930,6 +936,9 @@ private final class MultipartFetchManager {
}
case .hashesMissing:
break
case .webfileNotAvailable:
strongSelf.completeSize = 0
strongSelf.checkState()
}
}))
}

View file

@ -65,8 +65,17 @@ func bufferedFetch(_ signal: Signal<EngineMediaResource.Fetch.Result, EngineMedi
state.isCompleted = true
}
subscriber.putNext(.moveTempFile(file: file))
case .resourceSizeUpdated:
break
case let .resourceSizeUpdated(size):
if size == 0 {
let _ = state.with { state in
state.data.removeAll()
state.isCompleted = true
}
let tempFile = TempBox.shared.tempFile(fileName: "file")
let _ = try? Data().write(to: URL(fileURLWithPath: tempFile.path), options: .atomic)
subscriber.putNext(.moveTempFile(file: tempFile))
subscriber.putCompletion()
}
default:
assert(false)
break

View file

@ -1637,7 +1637,6 @@ final class PeerInfoHeaderNavigationButtonContainerNode: SparseNode {
buttonNode = PeerInfoHeaderNavigationButton()
self.leftButtonNodes[spec.key] = buttonNode
self.addSubnode(buttonNode)
buttonNode.isWhite = self.isWhite
buttonNode.action = { [weak self] _, gesture in
guard let strongSelf = self, let buttonNode = strongSelf.leftButtonNodes[spec.key] else {
return
@ -1659,6 +1658,8 @@ final class PeerInfoHeaderNavigationButtonContainerNode: SparseNode {
buttonNode.frame = buttonFrame
buttonNode.alpha = 0.0
transition.updateAlpha(node: buttonNode, alpha: alphaFactor * alphaFactor)
buttonNode.isWhite = self.isWhite
} else {
transition.updateFrameAdditiveToCenter(node: buttonNode, frame: buttonFrame)
transition.updateAlpha(node: buttonNode, alpha: alphaFactor * alphaFactor)
@ -1722,7 +1723,6 @@ final class PeerInfoHeaderNavigationButtonContainerNode: SparseNode {
buttonNode = PeerInfoHeaderNavigationButton()
self.rightButtonNodes[key] = buttonNode
self.addSubnode(buttonNode)
buttonNode.isWhite = self.isWhite
}
buttonNode.action = { [weak self] _, gesture in
guard let strongSelf = self, let buttonNode = strongSelf.rightButtonNodes[key] else {
@ -1744,6 +1744,8 @@ final class PeerInfoHeaderNavigationButtonContainerNode: SparseNode {
}
let alphaFactor: CGFloat = spec.isForExpandedView ? expandFraction : (1.0 - expandFraction)
if wasAdded {
buttonNode.isWhite = self.isWhite
if key == .moreToSearch {
buttonNode.layer.animateScale(from: 0.001, to: 1.0, duration: 0.2)
}