Changeset 1092
- Timestamp:
- Nov 16, 2006, 7:32:01 PM (16 years ago)
- Location:
- trunk/macosx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Torrent.h
r1084 r1092 96 96 - (void) trashTorrent; 97 97 98 - (BOOL) remainingDiskSpaceForTorrent; 98 - (BOOL) alertForRemainingDiskSpace; 99 - (BOOL) alertForDriveAvailable; 99 100 100 101 - (NSImage *) icon; -
trunk/macosx/Torrent.m
r1091 r1092 211 211 { 212 212 //move file from incomplete folder to download folder 213 #warning check if volume exists 213 214 if (fUseIncompleteFolder && ![[self downloadFolder] isEqualToString: fDownloadFolder]) 214 215 { … … 413 414 fFinishedSeeding = NO; 414 415 415 if (![self isActive] && [self remainingDiskSpaceForTorrent])416 if (![self isActive] && [self alertForDriveAvailable] && [self alertForRemainingDiskSpace]) 416 417 tr_torrentStart(fHandle); 417 418 } … … 514 515 } 515 516 516 - (BOOL) remainingDiskSpaceForTorrent517 - (BOOL) alertForRemainingDiskSpace 517 518 { 518 519 if ([self progress] >= 1.0) 519 520 return YES; 520 521 521 NSString * location = [self dataLocation],522 * volume = [[[NSFileManager defaultManager] componentsToDisplayForPath: location]objectAtIndex: 0];523 NSDictionary * fsAttributes = [[NSFileManager defaultManager] fileSystemAttributesAtPath: location];522 NSString * volumeName = [[[NSFileManager defaultManager] componentsToDisplayForPath: [self downloadFolder]] 523 objectAtIndex: 0]; 524 NSDictionary * fsAttributes = [[NSFileManager defaultManager] fileSystemAttributesAtPath: [self dataLocation]]; 524 525 uint64_t remainingSpace = [[fsAttributes objectForKey: NSFileSystemFreeSize] unsignedLongLongValue], 525 526 torrentRemaining = [self size] - (uint64_t)[self downloadedValid]; 526 527 527 /*NSLog(@"Volume: %@", volume );528 /*NSLog(@"Volume: %@", volumeName); 528 529 NSLog(@"Remaining disk space: %qu (%@)", remainingSpace, [NSString stringForFileSize: remainingSpace]); 529 530 NSLog(@"Torrent remaining size: %qu (%@)", torrentRemaining, [NSString stringForFileSize: torrentRemaining]);*/ 530 531 531 if (volume && remainingSpace <= torrentRemaining)532 if (volumeName && remainingSpace <= torrentRemaining) 532 533 { 533 534 NSAlert * alert = [[NSAlert alloc] init]; … … 536 537 "Torrent file disk space alert -> title"), [self name]]]; 537 538 [alert setInformativeText: [NSString stringWithFormat: 538 NSLocalizedString(@"The transfer will be paused. Clear up space on %@to continue.",539 "Torrent file disk space alert -> message"), volume ]];539 NSLocalizedString(@"The transfer will be paused. Clear up space on \"%@\" to continue.", 540 "Torrent file disk space alert -> message"), volumeName]]; 540 541 [alert addButtonWithTitle: NSLocalizedString(@"OK", "Torrent file disk space alert -> button")]; 541 542 [alert addButtonWithTitle: NSLocalizedString(@"Download Anyway", "Torrent file disk space alert -> button")]; … … 549 550 return YES; 550 551 } 552 return YES; 553 } 554 555 - (BOOL) alertForDriveAvailable 556 { 557 NSArray * pathComponents = [[self downloadFolder] pathComponents]; 558 if ([pathComponents count] < 3) 559 return YES; 560 561 NSString * volume = [[[pathComponents objectAtIndex: 0] stringByAppendingPathComponent: 562 [pathComponents objectAtIndex: 1]] stringByAppendingPathComponent: [pathComponents objectAtIndex: 2]]; 563 NSString * volumeName = [pathComponents objectAtIndex: 2]; 564 565 /*NSLog(@"%@", [self downloadFolder]); 566 NSLog(@"Volume: %@", volume);*/ 567 568 if (![[NSFileManager defaultManager] fileExistsAtPath: volume]) 569 { 570 NSAlert * alert = [[NSAlert alloc] init]; 571 [alert setMessageText: [NSString stringWithFormat: 572 NSLocalizedString(@"The volume for downloading \"%@\" cannot be found.", 573 "Volume cannot be found alert -> title"), [self name]]]; 574 [alert setInformativeText: [NSString stringWithFormat: 575 NSLocalizedString(@"The transfer will be paused. Mount the volume \"%@\" to continue.", 576 "Volume cannot be found alert -> message"), volumeName]]; 577 [alert addButtonWithTitle: NSLocalizedString(@"OK", "Volume cannot be found alert -> button")]; 578 #warning should choose new directory 579 [alert addButtonWithTitle: NSLocalizedString(@"Download Anyway", "Volume cannot be found alert -> button")]; 580 581 if ([alert runModal] == NSAlertFirstButtonReturn) 582 { 583 [[NSNotificationCenter defaultCenter] postNotificationName: @"StoppedDownloading" object: self]; 584 return NO; 585 } 586 else 587 return YES; 588 } 589 551 590 return YES; 552 591 }
Note: See TracChangeset
for help on using the changeset viewer.