mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Dispose temp file
This commit is contained in:
parent
4ee5f8487a
commit
e24920ae88
@ -258,7 +258,7 @@ private final class ImportManager {
|
||||
if !pathExtension.isEmpty, let value = TGMimeTypeMap.mimeType(forExtension: pathExtension) {
|
||||
mimeType = value
|
||||
}
|
||||
return ChatHistoryImport.uploadMedia(account: account, session: session, file: tempFile, fileName: entry.0.path, mimeType: mimeType, type: entry.2)
|
||||
return ChatHistoryImport.uploadMedia(account: account, session: session, file: tempFile, disposeFileAfterDone: true, fileName: entry.0.path, mimeType: mimeType, type: entry.2)
|
||||
|> mapError { error -> ImportError in
|
||||
switch error {
|
||||
case .chatAdminRequired:
|
||||
|
@ -107,7 +107,7 @@ public enum ChatHistoryImport {
|
||||
case chatAdminRequired
|
||||
}
|
||||
|
||||
public static func uploadMedia(account: Account, session: Session, file: TempBoxFile, fileName: String, mimeType: String, type: MediaType) -> Signal<Float, UploadMediaError> {
|
||||
public static func uploadMedia(account: Account, session: Session, file: TempBoxFile, disposeFileAfterDone: Bool, fileName: String, mimeType: String, type: MediaType) -> Signal<Float, UploadMediaError> {
|
||||
var forceNoBigParts = true
|
||||
guard let size = fileSize(file.path), size != 0 else {
|
||||
return .single(1.0)
|
||||
@ -160,6 +160,11 @@ public enum ChatHistoryImport {
|
||||
|> mapToSignal { result -> Signal<Float, UploadMediaError> in
|
||||
return .single(1.0)
|
||||
}
|
||||
|> afterDisposed {
|
||||
if disposeFileAfterDone {
|
||||
TempBox.shared.dispose(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user