1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-21 13:46:52 +00:00

First attempts at warning about not enough disk space (and stopping the offending torrents). Right now this occurs when the torrent is started.

This commit is contained in:
Mitchell Livingston 2006-09-28 00:32:26 +00:00
parent a1983664f2
commit 9881f7b6ef
2 changed files with 33 additions and 6 deletions

View file

@ -86,6 +86,8 @@
- (void) trashData;
- (void) trashTorrent;
- (BOOL) remainingDiskSpaceForTorrent;
- (NSImage *) icon;
- (NSImage *) iconFlipped;
- (NSImage *) iconSmall;

View file

@ -317,13 +317,11 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
- (void) startTransfer
{
if (![self isActive])
{
fWaitToStart = NO;
fFinishedSeeding = NO;
if (![self isActive] && [self remainingDiskSpaceForTorrent])
tr_torrentStart(fHandle);
fFinishedSeeding = NO;
fWaitToStart = NO;
}
}
- (void) stopTransfer
@ -416,6 +414,33 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
[self trashFile: [self publicTorrentLocation]];
}
- (BOOL) remainingDiskSpaceForTorrent
{
if ([self progress] >= 1.0)
return YES;
NSDictionary * fsAttributes = [[NSFileManager defaultManager] fileSystemAttributesAtPath: [self dataLocation]];
float remainingSpace = [[fsAttributes objectForKey: NSFileSystemFreeSize] floatValue],
torrentRemaining = (float)[self size] * (1.0 - [self progress]);
NSLog(@"Remaining disk space: %f", remainingSpace);
NSLog(@"Torrent remaining size: %f", torrentRemaining);
if (remainingSpace - torrentRemaining <= 10240.0)
{
NSAlert * alert = [[NSAlert alloc] init];
[alert setMessageText: [NSString stringWithFormat: @"Not enough remaining disk space to download \"%@\" completely.",
[self name]]];
[alert setInformativeText: @"The transfer has been paused. Clear up space on your disk to continue."];
[alert runModal];
return NO;
}
return YES;
}
- (NSImage *) icon
{
return fIcon;