Changeset 7052
- Timestamp:
- Nov 5, 2008, 12:42:03 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Torrent.m
r7049 r7052 551 551 NSDictionary * systemAttributes = onLeopard ? [fileManager attributesOfFileSystemForPath: downloadFolder error: NULL] 552 552 : [fileManager fileSystemAttributesAtPath: downloadFolder]; 553 uint64_t remainingSpace = [[systemAttributes objectForKey: NSFileSystemFreeSize] unsignedLongLongValue], neededSpace = 0; 554 555 //if the size left is less then remaining space, then there is enough space regardless of preallocation 556 if (remainingSpace < [self sizeLeft]) 557 { 558 [self updateFileStat]; 553 uint64_t remainingSpace = [[systemAttributes objectForKey: NSFileSystemFreeSize] unsignedLongLongValue], 554 neededSpace = tr_torrentGetBytesLeftToAllocate(fHandle); 555 556 if (remainingSpace < neededSpace) 557 { 558 NSAlert * alert = [[NSAlert alloc] init]; 559 [alert setMessageText: [NSString stringWithFormat: 560 NSLocalizedString(@"Not enough remaining disk space to download \"%@\" completely.", 561 "Torrent disk space alert -> title"), [self name]]]; 562 [alert setInformativeText: [NSString stringWithFormat: NSLocalizedString(@"The transfer will be paused." 563 " Clear up space on %@ or deselect files in the torrent inspector to continue.", 564 "Torrent disk space alert -> message"), volumeName]]; 565 [alert addButtonWithTitle: NSLocalizedString(@"OK", "Torrent disk space alert -> button")]; 566 [alert addButtonWithTitle: NSLocalizedString(@"Download Anyway", "Torrent disk space alert -> button")]; 559 567 560 //determine amount needed 561 for (NSInteger i = 0; i < [self fileCount]; i++) 568 if (onLeopard) 562 569 { 563 if (tr_torrentGetFileDL(fHandle, i)) 564 { 565 tr_file * file = &fInfo->files[i]; 566 567 neededSpace += file->length; 568 569 NSString * path = [downloadFolder stringByAppendingPathComponent: [NSString stringWithUTF8String: file->name]]; 570 NSDictionary * fileAttributes = onLeopard ? [fileManager attributesOfItemAtPath: path error: NULL] 571 : [fileManager fileAttributesAtPath: path traverseLink: NO]; 572 if (fileAttributes) 573 { 574 unsigned long long fileSize = [[fileAttributes objectForKey: NSFileSize] unsignedLongLongValue]; 575 if (fileSize < neededSpace) 576 neededSpace -= fileSize; 577 else 578 neededSpace = 0; 579 } 580 } 570 [alert setShowsSuppressionButton: YES]; 571 [[alert suppressionButton] setTitle: NSLocalizedString(@"Do not check disk space again", 572 "Torrent disk space alert -> button")]; 581 573 } 574 else 575 [alert addButtonWithTitle: NSLocalizedString(@"Always Download", "Torrent disk space alert -> button")]; 576 577 NSInteger result = [alert runModal]; 578 if ((onLeopard ? [[alert suppressionButton] state] == NSOnState : result == NSAlertThirdButtonReturn)) 579 [fDefaults setBool: NO forKey: @"WarningRemainingSpace"]; 580 [alert release]; 582 581 583 if (remainingSpace < neededSpace) 584 { 585 NSAlert * alert = [[NSAlert alloc] init]; 586 [alert setMessageText: [NSString stringWithFormat: 587 NSLocalizedString(@"Not enough remaining disk space to download \"%@\" completely.", 588 "Torrent disk space alert -> title"), [self name]]]; 589 [alert setInformativeText: [NSString stringWithFormat: NSLocalizedString(@"The transfer will be paused." 590 " Clear up space on %@ or deselect files in the torrent inspector to continue.", 591 "Torrent disk space alert -> message"), volumeName]]; 592 [alert addButtonWithTitle: NSLocalizedString(@"OK", "Torrent disk space alert -> button")]; 593 [alert addButtonWithTitle: NSLocalizedString(@"Download Anyway", "Torrent disk space alert -> button")]; 594 595 if (onLeopard) 596 { 597 [alert setShowsSuppressionButton: YES]; 598 [[alert suppressionButton] setTitle: NSLocalizedString(@"Do not check disk space again", 599 "Torrent disk space alert -> button")]; 600 } 601 else 602 [alert addButtonWithTitle: NSLocalizedString(@"Always Download", "Torrent disk space alert -> button")]; 603 604 NSInteger result = [alert runModal]; 605 if ((onLeopard ? [[alert suppressionButton] state] == NSOnState : result == NSAlertThirdButtonReturn)) 606 [fDefaults setBool: NO forKey: @"WarningRemainingSpace"]; 607 [alert release]; 608 609 return result != NSAlertFirstButtonReturn; 610 } 582 return result != NSAlertFirstButtonReturn; 611 583 } 612 584 }
Note: See TracChangeset
for help on using the changeset viewer.