Start and stop transfers for launch/quit without performing checks for waiting transfers, etc. This should fix saving the incorrect states of running transfers between launches.

This commit is contained in:
Mitchell Livingston 2006-07-02 22:59:23 +00:00
parent cb9a16a0bd
commit e7ebf16d43
3 changed files with 13 additions and 7 deletions

View File

@ -302,7 +302,7 @@ static void sleepCallBack(void * controller, io_service_t y,
- (void) applicationWillTerminate: (NSNotification *) notification
{
// Stop updating the interface
//stop updating the interface
[fTimer invalidate];
//save history
@ -320,9 +320,9 @@ static void sleepCallBack(void * controller, io_service_t y,
if (fUpdateInProgress)
return;
//stop running torrents and wait for them to stop (5 seconds timeout)
[fTorrents makeObjectsPerformSelector: @selector(stopTransfer)];
//stop running transfers and wait for them to stop (5 seconds timeout)
[fTorrents makeObjectsPerformSelector: @selector(stopTransferForQuit)];
NSDate * start = [NSDate date];
Torrent * torrent;
while ([fTorrents count] > 0)

View File

@ -66,6 +66,7 @@
- (void) update;
- (void) startTransfer;
- (void) stopTransfer;
- (void) stopTransferForQuit;
- (void) removeForever;
- (void) sleep;
- (void) wakeUp;

View File

@ -74,7 +74,7 @@
NSString * paused;
if (!(paused = [history objectForKey: @"Paused"]) || [paused isEqualToString: @"NO"])
[self startTransfer];
tr_torrentStart(fHandle);
}
return self;
}
@ -251,6 +251,12 @@
}
}
- (void) stopTransferForQuit
{
if ([self isActive])
tr_torrentStop(fHandle);
}
- (void) removeForever
{
if (fPrivateTorrent)
@ -607,6 +613,7 @@
fWaitToStart = waitToStart ? [waitToStart boolValue]
: ![[fDefaults stringForKey: @"StartSetting"] isEqualToString: @"Manual"];
fOrderValue = orderValue ? [orderValue intValue] : tr_torrentCount(fLib) - 1;
NSString * fileType = fInfo->multifile ? NSFileTypeForHFSTypeCode('fldr') : [[self name] pathExtension];
fIcon = [[NSWorkspace sharedWorkspace] iconForFileType: fileType];
@ -617,8 +624,6 @@
fProgressString = [[NSMutableString alloc] initWithCapacity: 50];
fStatusString = [[NSMutableString alloc] initWithCapacity: 75];
fOrderValue = orderValue ? [orderValue intValue] : tr_torrentCount(fLib) - 1;
[self update];
return self;