mirror of
https://github.com/transmission/transmission
synced 2025-03-03 10:15:45 +00:00
speed up check for enough remaining space by first determining if there is enough space to download what's needed ignoring preallocation
This commit is contained in:
parent
ec34995cff
commit
4f7742d422
2 changed files with 43 additions and 41 deletions
|
@ -547,49 +547,53 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
: [fileManager fileSystemAttributesAtPath: downloadFolder];
|
||||
uint64_t remainingSpace = [[systemAttributes objectForKey: NSFileSystemFreeSize] unsignedLongLongValue], neededSpace = 0;
|
||||
|
||||
[self updateFileStat];
|
||||
|
||||
//determine amount needed
|
||||
int i;
|
||||
for (i = 0; i < [self fileCount]; i++)
|
||||
//if the size left is less then remaining space, then there is enough space regardless of preallocation
|
||||
if (remainingSpace < [self sizeLeft])
|
||||
{
|
||||
if (tr_torrentGetFileDL(fHandle, i))
|
||||
[self updateFileStat];
|
||||
|
||||
//determine amount needed
|
||||
int i;
|
||||
for (i = 0; i < [self fileCount]; i++)
|
||||
{
|
||||
tr_file * file = &fInfo->files[i];
|
||||
|
||||
neededSpace += file->length;
|
||||
|
||||
NSString * path = [downloadFolder stringByAppendingPathComponent: [NSString stringWithUTF8String: file->name]];
|
||||
NSDictionary * fileAttributes = onLeopard ? [fileManager attributesOfItemAtPath: path error: NULL]
|
||||
: [fileManager fileAttributesAtPath: path traverseLink: NO];
|
||||
if (fileAttributes)
|
||||
neededSpace -= [[fileAttributes objectForKey: NSFileSize] unsignedLongLongValue];
|
||||
if (tr_torrentGetFileDL(fHandle, i))
|
||||
{
|
||||
tr_file * file = &fInfo->files[i];
|
||||
|
||||
neededSpace += file->length;
|
||||
|
||||
NSString * path = [downloadFolder stringByAppendingPathComponent: [NSString stringWithUTF8String: file->name]];
|
||||
NSDictionary * fileAttributes = onLeopard ? [fileManager attributesOfItemAtPath: path error: NULL]
|
||||
: [fileManager fileAttributesAtPath: path traverseLink: NO];
|
||||
if (fileAttributes)
|
||||
neededSpace -= [[fileAttributes objectForKey: NSFileSize] unsignedLongLongValue];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (remainingSpace < neededSpace)
|
||||
{
|
||||
NSAlert * alert = [[NSAlert alloc] init];
|
||||
[alert setMessageText: [NSString stringWithFormat:
|
||||
NSLocalizedString(@"Not enough remaining disk space to download \"%@\" completely.",
|
||||
"Torrent file disk space alert -> title"), [self name]]];
|
||||
[alert setInformativeText: [NSString stringWithFormat: NSLocalizedString(@"The transfer will be paused."
|
||||
" Clear up space on %@ or deselect files in the torrent inspector to continue.",
|
||||
"Torrent file disk space alert -> message"), volumeName]];
|
||||
[alert addButtonWithTitle: NSLocalizedString(@"OK", "Torrent file disk space alert -> button")];
|
||||
[alert addButtonWithTitle: NSLocalizedString(@"Download Anyway", "Torrent file disk space alert -> button")];
|
||||
|
||||
if (onLeopard)
|
||||
[alert setShowsSuppressionButton: YES];
|
||||
else
|
||||
[alert addButtonWithTitle: NSLocalizedString(@"Always Download", "Torrent file disk space alert -> button")];
|
||||
if (remainingSpace < neededSpace)
|
||||
{
|
||||
NSAlert * alert = [[NSAlert alloc] init];
|
||||
[alert setMessageText: [NSString stringWithFormat:
|
||||
NSLocalizedString(@"Not enough remaining disk space to download \"%@\" completely.",
|
||||
"Torrent file disk space alert -> title"), [self name]]];
|
||||
[alert setInformativeText: [NSString stringWithFormat: NSLocalizedString(@"The transfer will be paused."
|
||||
" Clear up space on %@ or deselect files in the torrent inspector to continue.",
|
||||
"Torrent file disk space alert -> message"), volumeName]];
|
||||
[alert addButtonWithTitle: NSLocalizedString(@"OK", "Torrent file disk space alert -> button")];
|
||||
[alert addButtonWithTitle: NSLocalizedString(@"Download Anyway", "Torrent file disk space alert -> button")];
|
||||
|
||||
if (onLeopard)
|
||||
[alert setShowsSuppressionButton: YES];
|
||||
else
|
||||
[alert addButtonWithTitle: NSLocalizedString(@"Always Download", "Torrent file disk space alert -> button")];
|
||||
|
||||
NSInteger result = [alert runModal];
|
||||
if ((onLeopard ? [[alert suppressionButton] state] == NSOnState : result == NSAlertThirdButtonReturn))
|
||||
[fDefaults setBool: NO forKey: @"WarningRemainingSpace"];
|
||||
[alert release];
|
||||
|
||||
return result != NSAlertFirstButtonReturn;
|
||||
NSInteger result = [alert runModal];
|
||||
if ((onLeopard ? [[alert suppressionButton] state] == NSOnState : result == NSAlertThirdButtonReturn))
|
||||
[fDefaults setBool: NO forKey: @"WarningRemainingSpace"];
|
||||
[alert release];
|
||||
|
||||
return result != NSAlertFirstButtonReturn;
|
||||
}
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
|
|
|
@ -821,9 +821,7 @@
|
|||
{
|
||||
BOOL ratio = [fDefaults boolForKey: @"DisplayGroupRowRatio"];
|
||||
|
||||
NSTableColumn * dlTableColumn = [self tableColumnWithIdentifier: @"DL"];
|
||||
|
||||
[dlTableColumn setHidden: ratio];
|
||||
[[self tableColumnWithIdentifier: @"DL"] setHidden: ratio];
|
||||
[[self tableColumnWithIdentifier: @"DL Image"] setHidden: ratio];
|
||||
|
||||
//change size of image column
|
||||
|
|
Loading…
Reference in a new issue