Skip to content

Commit c95dfaa

Browse files
Reoder file deletion to be more future proof on errors
1 parent 251fdb2 commit c95dfaa

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Monal/Classes/MLFiletransfer.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,15 +500,17 @@ +(void) deleteFileForMessage:(MLMessage*) msg
500500
{
501501
if(![msg.messageType isEqualToString:kMessageTypeFiletransfer])
502502
return;
503-
DDLogInfo(@"Deleting file for url %@", msg.messageText);
504503
MLFiletransferInfo* info = msg.fileInfo;
505-
DDLogDebug(@"Deleting file in cache: %@", info.cacheFilePath);
506-
[_fileManager removeItemAtPath:info.cacheFilePath error:nil];
504+
if(info.downloadState < DownloadStateComplete)
505+
return;
506+
DDLogInfo(@"Deleting file for url %@", msg.messageText);
507507
if([info.mimeType hasPrefix:@"video/"])
508508
{
509509
DDLogVerbose(@"Deleting video thumbnail stored at %@", msg.fileInfo.thumbnailURL.path);
510510
[_fileManager removeItemAtPath:msg.fileInfo.thumbnailURL.path error:nil];
511511
}
512+
DDLogDebug(@"Deleting file in cache: %@", info.cacheFilePath);
513+
[_fileManager removeItemAtPath:info.cacheFilePath error:nil];
512514
}
513515

514516
+(MLHandler*) prepareDataUpload:(NSData*) data

0 commit comments

Comments
 (0)