Delete video files in temp folder when the upload is done or has failed

This commit is contained in:
Arnfried Griesert
2024-02-09 09:33:50 +01:00
parent 95f2332738
commit 315e040d93
4 changed files with 42 additions and 6 deletions
+24 -2
View File
@@ -3560,13 +3560,35 @@ static const CGFloat kCellVisibilityMinimumHeight = 8.0;
- (void)roomInputToolbarView:(MXKRoomInputToolbarView*)toolbarView sendVideoAsset:(AVAsset*)videoAsset withThumbnail:(UIImage*)videoThumbnail
{
// Let the datasource send it and manage the local echo
[roomDataSource sendVideoAsset:videoAsset withThumbnail:videoThumbnail success:nil failure:^(NSError *error)
{
[roomDataSource sendVideoAsset:videoAsset withThumbnail:videoThumbnail success:^(NSString *eventId) {
// bwi: 5365
NSURL *url = [(AVURLAsset *)videoAsset URL];
if(url) {
[self deleteFileAtURL: url];
}
} failure:^(NSError *error) {
// Nothing to do. The video is marked as unsent in the room history by the datasource
MXLogDebug(@"[MXKRoomViewController] sendVideo failed.");
// bwi: 5365
NSURL *url = [(AVURLAsset *)videoAsset URL];
if(url) {
[self deleteFileAtURL: url];
}
}];
}
- (void)deleteFileAtURL:(NSURL *)url {
if (url == nil) {
return;
}
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil;
if (![fileManager removeItemAtURL:url error:&error]) {
MXLogDebug(@"Cannot delete file at %@", [url absoluteString])
MXLogDebug(@"%@", [error localizedDescription])
}
}
- (void)roomInputToolbarView:(MXKRoomInputToolbarView*)toolbarView sendFile:(NSURL *)fileLocalURL withMimeType:(NSString*)mimetype
{
// Let the datasource send it and manage the local echo