|
|
@@ -121,6 +121,12 @@
|
|
|
self.formatterTime = [self timeF:self.timestamp];
|
|
|
// 其他自定义字段...
|
|
|
self.readStatus = [self getReadStatus];
|
|
|
+
|
|
|
+ BOOL contain = [[NSFileManager defaultManager] fileExistsAtPath:self.localurl];
|
|
|
+ NSString *localPath = [self checkHasLocalPath];
|
|
|
+ if (!contain && localPath.length) {
|
|
|
+ self.localurl = localPath;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- (void)exchangeModelWithModel:(ChatMessageModel *)model{
|
|
|
@@ -393,6 +399,7 @@
|
|
|
if (loading) {
|
|
|
loading(100);
|
|
|
}
|
|
|
+ NSLog(@"downloadFileIfNeed 0: %@", localFileurl);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -402,9 +409,8 @@
|
|
|
NSString *fileExtension = [fileName pathExtension];
|
|
|
NSString *newfileName = [NSString stringWithFormat:@"%@.%@", self.msgId,fileExtension];
|
|
|
documentsDirectoryURL = [documentsDirectoryURL URLByAppendingPathComponent:newfileName];
|
|
|
- NSLog(@"文件本地路径:%@",documentsDirectoryURL.path);
|
|
|
if ([[NSFileManager defaultManager] fileExistsAtPath:documentsDirectoryURL.path]){
|
|
|
- NSLog(@"文件已经存在本地");
|
|
|
+ NSLog(@"downloadFileIfNeed 1: %@", documentsDirectoryURL.path);
|
|
|
NSMutableDictionary *mutableDict = [self.formerMessage mutableCopy];
|
|
|
NSMutableDictionary *extend = [self.formerMessage[@"extend"] mutableCopy];
|
|
|
[extend setObject:documentsDirectoryURL.path forKey:@"localurl"];
|
|
|
@@ -503,4 +509,25 @@
|
|
|
return _customFileSize;
|
|
|
}
|
|
|
|
|
|
+- (NSString *)checkHasLocalPath {
|
|
|
+ NSString *localFileurl = [self.localurl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLPathAllowedCharacterSet]];
|
|
|
+ if (self.localurl.length != 0 && [[NSFileManager defaultManager] fileExistsAtPath:localFileurl]){
|
|
|
+ self.customFileSize = [self getFileSize];
|
|
|
+ NSLog(@"checkHasLocalPath 0: %@", localFileurl);
|
|
|
+ return localFileurl;
|
|
|
+ }
|
|
|
+
|
|
|
+ NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
|
|
|
+ NSURL *tempUrl = [NSURL URLWithString:self.url];
|
|
|
+ NSString *fileName = tempUrl.lastPathComponent;
|
|
|
+ NSString *fileExtension = [fileName pathExtension];
|
|
|
+ NSString *newfileName = [NSString stringWithFormat:@"%@.%@", self.msgId,fileExtension];
|
|
|
+ NSString *path = [documentsDirectoryURL URLByAppendingPathComponent:newfileName].path;
|
|
|
+ if ([[NSFileManager defaultManager] fileExistsAtPath:path]){
|
|
|
+ NSLog(@"checkHasLocalPath 0: %@", path);
|
|
|
+ return path;
|
|
|
+ }
|
|
|
+ return nil;
|
|
|
+}
|
|
|
+
|
|
|
@end
|