diff --git a/Transmission.xcodeproj/project.pbxproj b/Transmission.xcodeproj/project.pbxproj index 1a169c1a2..ec5cd092f 100644 --- a/Transmission.xcodeproj/project.pbxproj +++ b/Transmission.xcodeproj/project.pbxproj @@ -2223,6 +2223,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_WARN_UNUSED_VARIABLE = NO; MACOSX_DEPLOYMENT_TARGET = 10.4; PREBINDING = NO; SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk"; @@ -2239,6 +2240,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_WARN_UNUSED_VARIABLE = NO; MACOSX_DEPLOYMENT_TARGET = 10.4; PREBINDING = NO; SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk"; diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 3e338a3c8..f76eabf8c 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -536,11 +536,14 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * return YES; NSFileManager * fileManager = [NSFileManager defaultManager]; + NSString * downloadFolder = [self downloadFolder]; + BOOL onLeopard = [NSApp isOnLeopardOrBetter]; NSString * volumeName; - if ((volumeName = [[fileManager componentsToDisplayForPath: [self downloadFolder]] objectAtIndex: 0])) + if ((volumeName = [[fileManager componentsToDisplayForPath: downloadFolder] objectAtIndex: 0])) { - NSDictionary * systemAttributes = [fileManager fileSystemAttributesAtPath: [self downloadFolder]]; + NSDictionary * systemAttributes = onLeopard ? [fileManager attributesOfFileSystemForPath: downloadFolder error: NULL] + : [fileManager fileSystemAttributesAtPath: downloadFolder]; uint64_t remainingSpace = [[systemAttributes objectForKey: NSFileSystemFreeSize] unsignedLongLongValue], neededSpace = 0; [self updateFileStat]; @@ -553,21 +556,13 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * { tr_file * file = &fInfo->files[i]; - NSString * path = [[self downloadFolder] stringByAppendingPathComponent: [NSString stringWithUTF8String: file->name]]; - if ([fileManager fileExistsAtPath: path]) - { - NSDictionary * fileAttributes = [NSApp isOnLeopardOrBetter] ? [fileManager attributesOfItemAtPath: path error: NULL] + 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) - { - NSLog(@"Problems getting file information for \"%@\".", path); - continue; - } - - neededSpace += file->length - [[fileAttributes objectForKey: NSFileSize] unsignedLongLongValue]; - } - else - neededSpace += file->length; + if (fileAttributes) + neededSpace -= [[fileAttributes objectForKey: NSFileSize] unsignedLongLongValue]; } }