Skip to content

Commit adcf5f3

Browse files
committed
文件 - 兼容一下旧版本已下载的文件
1 parent ea85d03 commit adcf5f3

File tree

10 files changed

+24
-24
lines changed

10 files changed

+24
-24
lines changed

Coding_iOS/Controllers/FileListViewController.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ - (void)downloadFilesBtnClicked{
366366

367367
Coding_FileManager *manager = [Coding_FileManager sharedManager];
368368
for (ProjectFile *file in selectedFiles) {
369-
if ([file hasBeenDownload]) {//已下载
369+
if ([file diskFileUrl]) {//已下载
370370
downloadedCount++;
371371
DebugLog(@"%@: 已在队列", file.name);
372372
}else if ([file cDownloadTask]) {//正在下载
@@ -693,7 +693,7 @@ - (void)deleteFile:(ProjectFile *)file{
693693
__weak typeof(self) weakSelf = self;
694694
__weak typeof(file) weakFile = file;
695695

696-
NSURL *fileUrl = [file hasBeenDownload];
696+
NSURL *fileUrl = [file diskFileUrl];
697697
Coding_DownloadTask *cDownloadTask = [file cDownloadTask];
698698
UIActionSheet *actionSheet;
699699

@@ -740,7 +740,7 @@ - (void)deleteFile:(ProjectFile *)file fromDisk:(BOOL)fromDisk{
740740
[Coding_FileManager cancelCDownloadTaskForKey:file.storage_key];
741741
}
742742
// 删除本地文件
743-
NSURL *fileUrl = [file hasBeenDownload];
743+
NSURL *fileUrl = [file diskFileUrl];
744744
NSString *filePath = fileUrl.path;
745745
NSFileManager *fm = [NSFileManager defaultManager];
746746
if ([fm fileExistsAtPath:filePath]) {

Coding_iOS/Controllers/FileVersionsViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ - (void)doRemarkFileVersion:(FileVersion *)curVersion withRemarkStr:(NSString *)
187187
- (void)deleteFileVersion:(FileVersion *)curVersion{
188188
__weak typeof(self) weakSelf = self;
189189

190-
NSURL *fileUrl = [Coding_FileManager diskDownloadUrlForKey:curVersion.storage_key_for_disk];
190+
NSURL *fileUrl = curVersion.diskFileUrl;
191191
Coding_DownloadTask *cDownloadTask = [Coding_FileManager cDownloadTaskForKey:curVersion.storage_key];
192192
UIActionSheet *actionSheet;
193193

@@ -234,7 +234,7 @@ - (void)doDeleteFileVersion:(FileVersion *)curVersion fromDisk:(BOOL)fromDisk{
234234
[Coding_FileManager cancelCDownloadTaskForKey:curVersion.storage_key];
235235
}
236236
// 删除本地文件
237-
NSURL *fileUrl = [Coding_FileManager diskDownloadUrlForKey:curVersion.storage_key_for_disk];
237+
NSURL *fileUrl = curVersion.diskFileUrl;
238238
NSString *filePath = fileUrl.path;
239239
NSFileManager *fm = [NSFileManager defaultManager];
240240
if ([fm fileExistsAtPath:filePath]) {

Coding_iOS/Controllers/FileViewController.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ - (void)configContent{
101101
self.title = [self titleStr];
102102
[self setupNavigationItem];
103103

104-
NSURL *fileUrl = [self hasBeenDownload];
104+
NSURL *fileUrl = [self diskFileUrl];
105105
if (!fileUrl) {
106106
[self showDownloadView];
107107
}else{
@@ -359,7 +359,7 @@ - (void)goToFileInfo{
359359

360360
- (void)deleteCurFile{
361361
UIActionSheet *actionSheet;
362-
NSURL *fileUrl = [_curFile hasBeenDownload];
362+
NSURL *fileUrl = [_curFile diskFileUrl];
363363
Coding_DownloadTask *cDownloadTask = [_curFile cDownloadTask];
364364

365365
if (fileUrl) {
@@ -405,7 +405,7 @@ - (void)doDeleteCurFile:(ProjectFile *)file fromDisk:(BOOL)fromDisk{
405405
[Coding_FileManager cancelCDownloadTaskForKey:file.storage_key];
406406
}
407407
// 删除本地文件
408-
NSURL *fileUrl = [file hasBeenDownload];
408+
NSURL *fileUrl = [file diskFileUrl];
409409
NSString *filePath = fileUrl.path;
410410
NSFileManager *fm = [NSFileManager defaultManager];
411411
if ([fm fileExistsAtPath:filePath]) {
@@ -509,12 +509,12 @@ - (void)easeToolBar:(EaseToolBar *)toolBar didClickedIndex:(NSInteger)index{
509509
}
510510
}
511511
#pragma mark Data Value
512-
- (NSURL *)hasBeenDownload{
512+
- (NSURL *)diskFileUrl{
513513
NSURL *fileUrl;
514514
if (self.curVersion) {
515-
fileUrl = [self.curVersion hasBeenDownload];
515+
fileUrl = [self.curVersion diskFileUrl];
516516
}else{
517-
fileUrl = [self.curFile hasBeenDownload];
517+
fileUrl = [self.curFile diskFileUrl];
518518
}
519519
return fileUrl;
520520
}

Coding_iOS/Models/FileVersion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@
2525
//download
2626
- (DownloadState)downloadState;
2727
- (Coding_DownloadTask *)cDownloadTask;
28-
- (NSURL *)hasBeenDownload;
28+
- (NSURL *)diskFileUrl;
2929
@end

Coding_iOS/Models/FileVersion.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ - (NSString *)toDeletePath{
4646
//download
4747
- (DownloadState)downloadState{
4848
DownloadState state = DownloadStateDefault;
49-
if ([self hasBeenDownload]) {
49+
if ([self diskFileUrl]) {
5050
state = DownloadStateDownloaded;
5151
}else{
5252
Coding_DownloadTask *cDownloadTask = [self cDownloadTask];
@@ -65,7 +65,7 @@ - (DownloadState)downloadState{
6565
- (Coding_DownloadTask *)cDownloadTask{
6666
return [Coding_FileManager cDownloadTaskForKey:_storage_key];
6767
}
68-
- (NSURL *)hasBeenDownload{
69-
return [Coding_FileManager diskDownloadUrlForKey:self.storage_key_for_disk];
68+
- (NSURL *)diskFileUrl{
69+
return [Coding_FileManager diskDownloadUrlForKey:self.storage_key] ?: [Coding_FileManager diskDownloadUrlForKey:self.storage_key_for_disk];
7070
}
7171
@end

Coding_iOS/Models/ProjectFile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ typedef NS_ENUM(NSInteger, DownloadState){
3535

3636
- (DownloadState)downloadState;
3737
- (Coding_DownloadTask *)cDownloadTask;
38-
- (NSURL *)hasBeenDownload;
38+
- (NSURL *)diskFileUrl;
3939

4040
- (NSString *)downloadPath;
4141

Coding_iOS/Models/ProjectFile.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ - (BOOL)isEmpty{
7878

7979
- (DownloadState)downloadState{
8080
DownloadState state = DownloadStateDefault;
81-
if ([self hasBeenDownload]) {
81+
if ([self diskFileUrl]) {
8282
state = DownloadStateDownloaded;
8383
}else{
8484
Coding_DownloadTask *cDownloadTask = [self cDownloadTask];
@@ -121,8 +121,8 @@ - (NSString *)storage_key_for_disk{
121121
- (Coding_DownloadTask *)cDownloadTask{
122122
return [Coding_FileManager cDownloadTaskForKey:_storage_key];
123123
}
124-
- (NSURL *)hasBeenDownload{
125-
return [Coding_FileManager diskDownloadUrlForKey:self.storage_key_for_disk];
124+
- (NSURL *)diskFileUrl{
125+
return [Coding_FileManager diskDownloadUrlForKey:self.storage_key] ?: [Coding_FileManager diskDownloadUrlForKey:self.storage_key_for_disk];
126126
}
127127

128128
- (NSString *)toDeletePath{

Coding_iOS/Views/Cell/FileListFileCell.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ - (void)setFile:(ProjectFile *)file{
142142

143143
- (void)clickedByUser{
144144
Coding_FileManager *manager = [Coding_FileManager sharedManager];
145-
NSURL *fileUrl = [Coding_FileManager diskDownloadUrlForKey:_file.storage_key_for_disk];
145+
NSURL *fileUrl = _file.diskFileUrl;
146146
if (fileUrl) {//已经下载到本地了
147147
if (_showDiskFileBlock) {
148148
_showDiskFileBlock(fileUrl, _file);

Coding_iOS/Views/Cell/FileVersionCell.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ - (void)changeToState:(DownloadState)state{
164164

165165
- (void)clickedByUser{
166166
Coding_FileManager *manager = [Coding_FileManager sharedManager];
167-
NSURL *fileUrl = [Coding_FileManager diskDownloadUrlForKey:_curVersion.storage_key_for_disk];
167+
NSURL *fileUrl = _curVersion.diskFileUrl;
168168
if (fileUrl) {//已经下载到本地了
169169
if (_showDiskFileBlock) {
170170
_showDiskFileBlock(fileUrl, _curVersion);

Coding_iOS/Views/FileDownloadView.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ - (NSString *)owner_preview{
6666
- (NSString *)fileType{
6767
return [self.curData valueForKey:@"fileType"];
6868
}
69-
- (NSString *)storage_key{
70-
return [self.curData valueForKey:@"storage_key_for_disk"];
69+
- (NSURL *)diskFileUrl{
70+
return [self.curData valueForKey:@"diskFileUrl"];
7171
}
7272
- (NSString *)name{
7373
if (_version) {
@@ -281,7 +281,7 @@ - (void)updatePregress:(double)fractionCompleted{
281281

282282
- (void)clickedByUser{
283283
Coding_FileManager *manager = [Coding_FileManager sharedManager];
284-
NSURL *fileUrl = [Coding_FileManager diskDownloadUrlForKey:self.storage_key];
284+
NSURL *fileUrl = self.diskFileUrl;
285285
if (fileUrl) {//已经下载到本地了
286286
if (_otherMethodOpenBlock) {
287287
_otherMethodOpenBlock();

0 commit comments

Comments
 (0)