Browse Source

1.下载缓存读不到问题

huangxiaodong 1 year ago
parent
commit
178019fc61

+ 19 - 3
创维盒子/双子星云手机/NAS/recenFile/audioPlayListManager.m

@@ -248,10 +248,24 @@
         }
     }
     
+    //NSString *curFilePath = preDownloadModel.localPath;
+    NSString *curFilePath  = [[audioPlayListManager shareManager] getAudioCacheFullPathBy:preDownloadModel.name];
+    
     // 创建NSFileManager实例
     NSFileManager *fileManager = [NSFileManager defaultManager];
+    
     // 使用fileExistsAtPath方法检查文件是否存在
-    BOOL fileExists = [fileManager fileExistsAtPath:preDownloadModel.localPath];
+    BOOL fileExists = [fileManager fileExistsAtPath:curFilePath];
+    
+    // 再加一层判断看看
+    if(!fileExists){
+        NSDictionary *attributes = [fileManager attributesOfItemAtPath:curFilePath error:nil];
+        if (attributes) {
+            fileExists = YES;;
+        } else {
+            HLog(@"文件不存在:%@",filePath);
+        }
+    }
     
     
     if(preDownloadModel && preDownloadModel.isDownDoneType && fileExists){
@@ -316,14 +330,16 @@
         if([model.path isEqualToString:filePath]){
             if (model.isDownDoneType) {
                 if(model.localPath){
+                    NSString *curFilePath  = [[audioPlayListManager shareManager] getAudioCacheFullPathBy:model.name];
+                    
                     // 创建NSFileManager实例
                     NSFileManager *fileManager = [NSFileManager defaultManager];
               
                     // 使用fileExistsAtPath方法检查文件是否存在
-                    BOOL fileExists = [fileManager fileExistsAtPath:model.localPath];
+                    BOOL fileExists = [fileManager fileExistsAtPath:curFilePath];
               
                     if (fileExists) {
-                        return  model.localPath;
+                        return  curFilePath;
                     } else {
                         return @"";
                     }

+ 1 - 1
创维盒子/双子星云手机/NAS/recenFile/lastFileModel.h

@@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, assign) NSTimeInterval lastPreTime;//最后预览时间
 
 @property (nonatomic, assign) BOOL  isDownDoneType;//下载完成
-@property (nonatomic, copy) NSString*localPath;//本地缓存路径
+@property (nonatomic, copy) NSString*localPath;//本地缓存路径 不能直接用 每次都要重新取
 
 - (NSDictionary *)lastFileInfoFun;
 @end