Changeset 7661


Ignore:
Timestamp:
Jan 11, 2009, 12:59:59 AM (12 years ago)
Author:
livings124
Message:

(1.5x Mac) When removing local data only remove data from the torrent

Location:
branches/1.5x
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/1.5x/NEWS

    r7494 r7661  
    11NEWS file for Transmission <http://www.transmissionbt.com/>
     2
     31.50 (2009/01/dd)
     4<http://trac.transmissionbt.com/query?milestone=1.50&group=component&groupdesc=1&order=severity>
     5- All Platforms
     6   + IPv6 support
     7   + When removing local data only remove data from the torrent
     8- GTK+
     9   + Minor display improvements and HIG compliance
    210
    3111.42 (2008/12/24)
  • branches/1.5x/macosx/Torrent.h

    r7016 r7661  
    22 * $Id$
    33 *
    4  * Copyright (c) 2006-2008 Transmission authors and contributors
     4 * Copyright (c) 2006-2009 Transmission authors and contributors
    55 *
    66 * Permission is hereby granted, free of charge, to any person obtaining a
     
    6161   
    6262    tr_file_stat * fFileStat;
    63     NSArray * fFileList;
     63    NSArray * fFileList, * fFlatFileList;
    6464   
    6565    NSIndexSet * fPreviousFinishedIndexes;
     
    155155
    156156- (NSMutableArray *) allTrackers: (BOOL) separators;
     157- (NSArray *) allTrackersFlat;
    157158- (BOOL) updateAllTrackersForAdd: (NSMutableArray *) trackers;
    158159- (void) updateAllTrackersForRemove: (NSMutableArray *) trackers;
     
    241242- (NSInteger) fileCount;
    242243- (void) updateFileStat;
     244- (NSArray *) flatFileList;
    243245
    244246//methods require fileStats to have been updated recently to be accurate
  • branches/1.5x/macosx/Torrent.m

    r7069 r7661  
    22 * $Id$
    33 *
    4  * Copyright (c) 2006-2008 Transmission authors and contributors
     4 * Copyright (c) 2006-2009 Transmission authors and contributors
    55 *
    66 * Permission is hereby granted, free of charge, to any person obtaining a
     
    2828#import "NSApplicationAdditions.h"
    2929#import "NSStringAdditions.h"
    30 #import "metainfo.h"
    3130#import "utils.h" //tr_httpIsValidURL
    3231
     
    4544
    4645- (void) createFileList;
    47 - (void) insertPath: (NSMutableArray *) components forParent: (FileListNode *) parent fileSize: (uint64_t) size index: (NSInteger) index;
     46- (void) insertPath: (NSMutableArray *) components forParent: (FileListNode *) parent fileSize: (uint64_t) size
     47    index: (NSInteger) index flatList: (NSMutableArray *) flatFileList;
    4848
    4949- (void) completenessChange: (NSNumber *) status;
     
    5656- (void) updateAllTrackers: (NSMutableArray *) trackers;
    5757
    58 - (void) trashFile: (NSString *) path;
     58+ (void) trashFile: (NSString *) path;
    5959
    6060- (void) setTimeMachineExclude: (BOOL) exclude forPath: (NSString *) path;
     
    6666    [(Torrent *)torrentData performSelectorOnMainThread: @selector(completenessChange:)
    6767                withObject: [[NSNumber alloc] initWithInt: status] waitUntilDone: NO];
     68}
     69
     70int trashDataFile(const char * filename)
     71{
     72    [Torrent trashFile: [NSString stringWithUTF8String: filename]];
     73    return 0;
    6874}
    6975
     
    9096        }
    9197        else if (!fPublicTorrent)
    92             [self trashFile: path];
     98            [Torrent trashFile: path];
    9399        else;
    94100    }
     
    190196   
    191197    [fFileList release];
     198    [fFlatFileList release];
    192199   
    193200    [fQuickPauseDict release];
     
    221228- (void) changeDownloadFolder: (NSString *) folder
    222229{
     230    if (fDownloadFolder && [folder isEqualToString: fDownloadFolder])
     231        return;
     232   
    223233    [fDownloadFolder release];
    224234    fDownloadFolder = [folder retain];
     
    450460- (void) trashData
    451461{
    452     [self trashFile: [self dataLocation]];
     462    tr_torrentDeleteLocalData(fHandle, trashDataFile);
    453463}
    454464
     
    457467    if (fPublicTorrent)
    458468    {
    459         [self trashFile: fPublicTorrentLocation];
     469        [Torrent trashFile: fPublicTorrentLocation];
    460470        [fPublicTorrentLocation release];
    461471        fPublicTorrentLocation = nil;
     
    759769- (NSMutableArray *) allTrackers: (BOOL) separators
    760770{
    761     NSInteger count = fInfo->trackerCount, capacity = count;
    762     if (separators)
    763         capacity += fInfo->trackers[count-1].tier + 1;
     771    const NSInteger count = fInfo->trackerCount;
     772    const NSInteger capacity = separators ? count + fInfo->trackers[count-1].tier + 1 : count;
    764773    NSMutableArray * allTrackers = [NSMutableArray arrayWithCapacity: capacity];
    765774   
     
    776785   
    777786    return allTrackers;
     787}
     788
     789- (NSArray *) allTrackersFlat
     790{
     791    return [self allTrackers: NO];
    778792}
    779793
     
    982996    {
    983997        tr_peer_stat * peer = &peers[i];
    984         NSMutableDictionary * dict = [NSMutableDictionary dictionaryWithCapacity: 9];
     998        NSMutableDictionary * dict = [NSMutableDictionary dictionaryWithCapacity: 10];
    985999       
    9861000        [dict setObject: [NSNumber numberWithInt: peer->from] forKey: @"From"];
     
    9881002        [dict setObject: [NSNumber numberWithInt: peer->port] forKey: @"Port"];
    9891003        [dict setObject: [NSNumber numberWithFloat: peer->progress] forKey: @"Progress"];
     1004        [dict setObject: [NSNumber numberWithBool: peer->isSeed] forKey: @"Seed"];
    9901005        [dict setObject: [NSNumber numberWithBool: peer->isEncrypted] forKey: @"Encryption"];
    9911006        [dict setObject: [NSString stringWithUTF8String: peer->client] forKey: @"Client"];
     
    14261441        have += fFileStat[index].bytesCompleted;
    14271442   
    1428     NSAssert([node size], @"director in torrent file has size 0");
     1443    NSAssert([node size], @"directory in torrent file has size 0");
    14291444    return (CGFloat)have / [node size];
     1445}
     1446
     1447- (NSArray *) flatFileList
     1448{
     1449    return fFlatFileList;
    14301450}
    14311451
     
    17181738    {
    17191739        NSInteger count = [self fileCount];
    1720         NSMutableArray * fileList = [[NSMutableArray alloc] initWithCapacity: count];
     1740        NSMutableArray * fileList = [[NSMutableArray alloc] initWithCapacity: count],
     1741                    * flatFileList = [[NSMutableArray alloc] initWithCapacity: count];
    17211742       
    17221743        for (NSInteger i = 0; i < count; i++)
     
    17461767               
    17471768                [node insertIndex: i withSize: file->length];
    1748                 [self insertPath: pathComponents forParent: node fileSize: file->length index: i];
     1769                [self insertPath: pathComponents forParent: node fileSize: file->length index: i flatList: flatFileList];
    17491770            }
    17501771            else
     
    17521773                FileListNode * node = [[FileListNode alloc] initWithFileName: name path: path size: file->length index: i];
    17531774                [fileList addObject: node];
     1775                [flatFileList addObject: node];
    17541776                [node release];
    17551777            }
     
    17601782        fFileList = [[NSArray alloc] initWithArray: fileList];
    17611783        [fileList release];
     1784       
     1785        fFlatFileList = [[NSArray alloc] initWithArray: flatFileList];
     1786        [flatFileList release];
    17621787    }
    17631788    else
     
    17651790        FileListNode * node = [[FileListNode alloc] initWithFileName: [self name] path: @"" size: [self size] index: 0];
    17661791        fFileList = [[NSArray arrayWithObject: node] retain];
     1792        fFlatFileList = [fFileList copy];
    17671793        [node release];
    17681794    }
    17691795}
    17701796
    1771 - (void) insertPath: (NSMutableArray *) components forParent: (FileListNode *) parent fileSize: (uint64_t) size index: (NSInteger) index
     1797- (void) insertPath: (NSMutableArray *) components forParent: (FileListNode *) parent fileSize: (uint64_t) size
     1798    index: (NSInteger) index flatList: (NSMutableArray *) flatFileList
    17721799{
    17731800    NSString * name = [components objectAtIndex: 0];
     
    17891816            node = [[FileListNode alloc] initWithFolderName: name path: [parent fullPath]];
    17901817        else
     1818        {
    17911819            node = [[FileListNode alloc] initWithFileName: name path: [parent fullPath] size: size index: index];
     1820            [flatFileList addObject: node];
     1821        }
    17921822       
    17931823        [parent insertChild: node];
     
    18001830       
    18011831        [components removeObjectAtIndex: 0];
    1802         [self insertPath: components forParent: node fileSize: size index: index];
     1832        [self insertPath: components forParent: node fileSize: size index: index flatList: flatFileList];
    18031833    }
    18041834}
     
    18291859    switch ([status intValue])
    18301860    {
    1831         case TR_CP_DONE:
    1832         case TR_CP_COMPLETE:
     1861        case TR_SEED:
     1862        case TR_PARTIAL_SEED:
    18331863            canMove = YES;
    18341864           
     
    18631893            break;
    18641894       
    1865         case TR_CP_INCOMPLETE:
     1895        case TR_LEECH:
    18661896            //do not allow to be backed up by Time Machine
    18671897            [self setTimeMachineExclude: YES forPath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]];
     
    19491979}
    19501980
    1951 - (void) trashFile: (NSString *) path
     1981+ (void) trashFile: (NSString *) path
    19521982{
    19531983    //attempt to move to trash
Note: See TracChangeset for help on using the changeset viewer.