Changeset 1359


Ignore:
Timestamp:
Jan 14, 2007, 8:22:51 PM (15 years ago)
Author:
livings124
Message:

don't download if folder doesn't exist, instead of just the volume to make it more compatible with new io code

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Torrent.h

    r1317 r1359  
    113113
    114114- (BOOL) alertForRemainingDiskSpace;
    115 - (BOOL) alertForVolumeAvailable;
    116 - (BOOL) alertForMoveVolumeAvailable;
     115- (BOOL) alertForFolderAvailable;
     116- (BOOL) alertForMoveFolderAvailable;
    117117
    118118- (NSImage *)   icon;
  • trunk/macosx/Torrent.m

    r1356 r1359  
    241241        //move file from incomplete folder to download folder
    242242        if (fUseIncompleteFolder && ![[self downloadFolder] isEqualToString: fDownloadFolder]
    243             && (canMove = [self alertForMoveVolumeAvailable]))
     243            && (canMove = [self alertForMoveFolderAvailable]))
    244244        {
    245245            tr_torrentStop(fHandle);
     
    451451    fFinishedSeeding = NO;
    452452   
    453     if (![self isActive] && [self alertForVolumeAvailable] && [self alertForRemainingDiskSpace])
     453    if (![self isActive] && [self alertForFolderAvailable] && [self alertForRemainingDiskSpace])
    454454    {
    455455        tr_torrentStart(fHandle);
     
    673673}
    674674
    675 - (BOOL) alertForVolumeAvailable
    676 {
    677     NSArray * pathComponents = [[self downloadFolder] pathComponents];
    678     if ([pathComponents count] < 3)
    679         return YES;
    680    
    681     NSString * volume = [[[pathComponents objectAtIndex: 0] stringByAppendingPathComponent:
    682                     [pathComponents objectAtIndex: 1]] stringByAppendingPathComponent: [pathComponents objectAtIndex: 2]];
    683    
    684     /*NSLog(@"%@", [self downloadFolder]);
    685     NSLog(@"Volume: %@", volume);*/
    686    
    687     if (![[NSFileManager defaultManager] fileExistsAtPath: volume])
    688     {
    689         NSString * volumeName = [pathComponents objectAtIndex: 2];
    690        
     675- (BOOL) alertForFolderAvailable
     676{
     677    if (access(tr_torrentGetFolder(fHandle), 0))
     678    {
    691679        NSAlert * alert = [[NSAlert alloc] init];
    692680        [alert setMessageText: [NSString stringWithFormat:
    693                                 NSLocalizedString(@"The volume for downloading \"%@\" cannot be found.",
    694                                     "Volume cannot be found alert -> title"), [self name]]];
     681                                NSLocalizedString(@"The folder for downloading \"%@\" cannot be found.",
     682                                    "Folder cannot be found alert -> title"), [self name]]];
    695683        [alert setInformativeText: [NSString stringWithFormat:
    696                         NSLocalizedString(@"The transfer will be paused. Mount the volume \"%@\" to continue.",
    697                                             "Volume cannot be found alert -> message"), volumeName]];
    698         [alert addButtonWithTitle: NSLocalizedString(@"OK", "Volume cannot be found alert -> button")];
    699         [alert addButtonWithTitle: [NSLocalizedString(@"Choose New Directory",
    700                                     "Volume cannot be found alert -> directory button") stringByAppendingEllipsis]];
     684                        NSLocalizedString(@"\"%@\" cannot be found. The transfer will be paused.",
     685                                            "Folder cannot be found alert -> message"), [self downloadFolder]]];
     686        [alert addButtonWithTitle: NSLocalizedString(@"OK", "Folder cannot be found alert -> button")];
     687        [alert addButtonWithTitle: [NSLocalizedString(@"Choose New Location",
     688                                    "Folder cannot be found alert -> location button") stringByAppendingEllipsis]];
    701689       
    702690        if ([alert runModal] != NSAlertFirstButtonReturn)
     
    750738}
    751739
    752 - (BOOL) alertForMoveVolumeAvailable
    753 {
    754     NSArray * pathComponents = [fDownloadFolder pathComponents];
    755     if ([pathComponents count] < 3)
    756         return YES;
    757    
    758     NSString * volume = [[[pathComponents objectAtIndex: 0] stringByAppendingPathComponent:
    759                     [pathComponents objectAtIndex: 1]] stringByAppendingPathComponent: [pathComponents objectAtIndex: 2]];
    760    
    761     /*NSLog(@"%@", [self downloadFolder]);
    762     NSLog(@"Volume: %@", volume);*/
    763    
    764     if (![[NSFileManager defaultManager] fileExistsAtPath: volume])
     740- (BOOL) alertForMoveFolderAvailable
     741{
     742    if (access([fDownloadFolder UTF8String], 0))
    765743    {
    766744        NSAlert * alert = [[NSAlert alloc] init];
    767745        [alert setMessageText: [NSString stringWithFormat:
    768746                                NSLocalizedString(@"The volume for moving the completed \"%@\" cannot be found.",
    769                                     "Move volume cannot be found alert -> title"), [self name]]];
    770         [alert setInformativeText: NSLocalizedString(@"The file will remain in its current location",
    771                                     "Move volume cannot be found alert -> message")];
    772         [alert addButtonWithTitle: NSLocalizedString(@"OK", "Move volume cannot be found alert -> button")];
     747                                    "Move folder cannot be found alert -> title"), [self name]]];
     748        [alert setInformativeText: [NSString stringWithFormat:
     749                                NSLocalizedString(@"\"%@\" cannot be found. The file will remain in its current location.",
     750                                    "Move folder cannot be found alert -> message"), fDownloadFolder]];
     751        [alert addButtonWithTitle: NSLocalizedString(@"OK", "Move folder cannot be found alert -> button")];
    773752       
    774753        [alert runModal];
Note: See TracChangeset for help on using the changeset viewer.