Changeset 2438


Ignore:
Timestamp:
Jul 19, 2007, 10:12:23 PM (16 years ago)
Author:
livings124
Message:

when checking remaining space, factor in preallocated space (but for now don't factor in non-selected files)

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/English.lproj/Localizable.strings

    r2424 r2438  
    512512
    513513/* Torrent file disk space alert -> message */
    514 "The transfer will be paused. Clear up space on %@ to continue." = "The transfer will be paused. Clear up space on %@ to continue.";
     514"The transfer will be paused. Clear up space on %@ or deselect files in the torrent inspector to continue." = "The transfer will be paused. Clear up space on %@ or deselect files in the torrent inspector to continue.";
    515515
    516516/* Removal confirm panel -> message part 1 */
  • trunk/macosx/Torrent.m

    r2424 r2438  
    808808    if ((volumeName = [[[NSFileManager defaultManager] componentsToDisplayForPath: [self downloadFolder]] objectAtIndex: 0]))
    809809    {
    810         NSDictionary * fsAttributes = [[NSFileManager defaultManager] fileSystemAttributesAtPath: [self downloadFolder]];
    811         uint64_t remainingSpace = [[fsAttributes objectForKey: NSFileSystemFreeSize] unsignedLongLongValue];
    812        
    813         #warning add  file size to remaining space and add total size
    814         if (remainingSpace <= fStat->left)
     810        NSDictionary * systemAttributes = [[NSFileManager defaultManager] fileSystemAttributesAtPath: [self downloadFolder]];
     811        uint64_t remainingSpace = [[systemAttributes objectForKey: NSFileSystemFreeSize] unsignedLongLongValue];
     812       
     813        uint64_t existingSize = 0;
     814        NSDirectoryEnumerator * enumerator;
     815        if (enumerator = [[NSFileManager defaultManager] enumeratorAtPath:
     816                    [[self downloadFolder] stringByAppendingPathComponent: [self name]]])
     817        {
     818            NSDictionary * fileAttributes;
     819            while ([enumerator nextObject])
     820            {
     821                fileAttributes = [enumerator fileAttributes];
     822                if (![[fileAttributes objectForKey: NSFileType] isEqualTo: NSFileTypeDirectory])
     823                    existingSize += [[fileAttributes objectForKey: NSFileSize] unsignedLongLongValue];
     824            }
     825        }
     826       
     827        #warning factor in checked files
     828        if (remainingSpace + existingSize <= [self size])
    815829        {
    816830            NSAlert * alert = [[NSAlert alloc] init];
     
    818832                                    NSLocalizedString(@"Not enough remaining disk space to download \"%@\" completely.",
    819833                                        "Torrent file disk space alert -> title"), [self name]]];
    820             [alert setInformativeText: [NSString stringWithFormat:
    821                             NSLocalizedString(@"The transfer will be paused. Clear up space on %@ to continue.",
    822                                                 "Torrent file disk space alert -> message"), volumeName]];
     834            [alert setInformativeText: [NSString stringWithFormat: NSLocalizedString(@"The transfer will be paused."
     835                                        " Clear up space on %@ or deselect files in the torrent inspector to continue.",
     836                                        "Torrent file disk space alert -> message"), volumeName]];
    823837            [alert addButtonWithTitle: NSLocalizedString(@"OK", "Torrent file disk space alert -> button")];
    824838            [alert addButtonWithTitle: NSLocalizedString(@"Download Anyway", "Torrent file disk space alert -> button")];
Note: See TracChangeset for help on using the changeset viewer.