warning if move folder doesn't exist, and a few releases

This commit is contained in:
Mitchell Livingston
2006-11-16 22:03:51 +00:00
parent 68fbb93eac
commit 9b75a6818a
4 changed files with 57 additions and 5 deletions

View File

@@ -956,6 +956,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
[alert setAlertStyle: NSWarningAlertStyle];
[alert runModal];
[alert release];
[torrents removeObjectAtIndex: 0];
[self copyTorrentFileForTorrents: torrents];

View File

@@ -195,6 +195,7 @@
[alert setAlertStyle: NSWarningAlertStyle];
[alert runModal];
[alert release];
}
}

View File

@@ -97,6 +97,7 @@
- (BOOL) alertForRemainingDiskSpace;
- (BOOL) alertForVolumeAvailable;
- (BOOL) alertForMoveVolumeAvailable;
- (NSImage *) icon;
- (NSImage *) iconFlipped;

View File

@@ -169,7 +169,6 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
[fShortStatusString release];
[fRemainingTimeString release];
[fBitmap release];
free(fPieces);
}
@@ -210,9 +209,11 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
//notification when downloading finished
if ([self justFinished])
{
BOOL canMove = YES;
//move file from incomplete folder to download folder
#warning check if volume exists
if (fUseIncompleteFolder && ![[self downloadFolder] isEqualToString: fDownloadFolder])
if (fUseIncompleteFolder && ![[self downloadFolder] isEqualToString: fDownloadFolder]
&& (canMove = [self alertForMoveVolumeAvailable]))
{
tr_torrentStop(fHandle);
if ([[NSFileManager defaultManager] movePath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]
@@ -221,6 +222,15 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
tr_torrentStart(fHandle);
}
if (!canMove)
{
fUseIncompleteFolder = NO;
[fDownloadFolder release];
fDownloadFolder = fIncompleteFolder;
fIncompleteFolder = nil;
}
[[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self];
}
@@ -549,6 +559,8 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
}
else
return YES;
[alert release];
}
return YES;
}
@@ -561,13 +573,14 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
NSString * volume = [[[pathComponents objectAtIndex: 0] stringByAppendingPathComponent:
[pathComponents objectAtIndex: 1]] stringByAppendingPathComponent: [pathComponents objectAtIndex: 2]];
NSString * volumeName = [pathComponents objectAtIndex: 2];
/*NSLog(@"%@", [self downloadFolder]);
NSLog(@"Volume: %@", volume);*/
if (![[NSFileManager defaultManager] fileExistsAtPath: volume])
{
NSString * volumeName = [pathComponents objectAtIndex: 2];
NSAlert * alert = [[NSAlert alloc] init];
[alert setMessageText: [NSString stringWithFormat:
NSLocalizedString(@"The volume for downloading \"%@\" cannot be found.",
@@ -598,6 +611,8 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
didEndSelector: @selector(destinationChoiceClosed:returnCode:contextInfo:) contextInfo: nil];
}
[alert release];
return NO;
}
@@ -607,7 +622,6 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
- (void) destinationChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (NSDictionary *) context
{
NSString * folder = [[openPanel filenames] objectAtIndex: 0];
NSLog(@"%@", folder);
if (code == NSOKButton)
{
if (fUseIncompleteFolder)
@@ -625,11 +639,46 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
[self startTransfer];
[self update];
#warning reload inspector
}
else
[[NSNotificationCenter defaultCenter] postNotificationName: @"StoppedDownloading" object: self];
}
- (BOOL) alertForMoveVolumeAvailable
{
NSArray * pathComponents = [fDownloadFolder pathComponents];
if ([pathComponents count] < 3)
return YES;
NSString * volume = [[[pathComponents objectAtIndex: 0] stringByAppendingPathComponent:
[pathComponents objectAtIndex: 1]] stringByAppendingPathComponent: [pathComponents objectAtIndex: 2]];
/*NSLog(@"%@", [self downloadFolder]);
NSLog(@"Volume: %@", volume);*/
if (![[NSFileManager defaultManager] fileExistsAtPath: volume])
{
NSString * volumeName = [pathComponents objectAtIndex: 2];
NSAlert * alert = [[NSAlert alloc] init];
[alert setMessageText: [NSString stringWithFormat:
NSLocalizedString(@"The volume for moving the completed \"%@\" cannot be found.",
"Move volume cannot be found alert -> title"), [self name]]];
[alert setInformativeText: [NSString stringWithFormat:
NSLocalizedString(@"The file will remain in its current location",
"Move volume cannot be found alert -> message"), volumeName]];
[alert addButtonWithTitle: NSLocalizedString(@"OK", "Move volume cannot be found alert -> button")];
[alert runModal];
[alert release];
return NO;
}
return YES;
}
- (NSImage *) icon
{