mirror of
https://github.com/transmission/transmission
synced 2025-03-15 16:29:34 +00:00
incomplete folder for downloading torrents
This commit is contained in:
parent
c111c4fb53
commit
4c36ac4a10
8 changed files with 91 additions and 10 deletions
|
@ -44,6 +44,8 @@
|
|||
<false/>
|
||||
<key>History</key>
|
||||
<array/>
|
||||
<key>IncompleteDownloadFolder</key>
|
||||
<string>~/Desktop</string>
|
||||
<key>InfoTab</key>
|
||||
<string>Info</string>
|
||||
<key>InfoVisible</key>
|
||||
|
@ -104,5 +106,7 @@
|
|||
<integer>20</integer>
|
||||
<key>UseAdvancedBar</key>
|
||||
<false/>
|
||||
<key>UseIncompleteDownloadFolder</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
2
macosx/English.lproj/PrefsWindow.nib/classes.nib
generated
2
macosx/English.lproj/PrefsWindow.nib/classes.nib
generated
|
@ -9,6 +9,7 @@
|
|||
folderSheetShow = id;
|
||||
helpForNetwork = id;
|
||||
importFolderSheetShow = id;
|
||||
incompleteFolderSheetShow = id;
|
||||
setAutoImport = id;
|
||||
setAutoSize = id;
|
||||
setAutoSpeedLimit = id;
|
||||
|
@ -31,6 +32,7 @@
|
|||
fFolderPopUp = NSPopUpButton;
|
||||
fGeneralView = NSView;
|
||||
fImportFolderPopUp = NSPopUpButton;
|
||||
fIncompleteFolderPopUp = NSPopUpButton;
|
||||
fNatCheck = NSButton;
|
||||
fNatStatusField = NSTextField;
|
||||
fNatStatusImage = NSImageView;
|
||||
|
|
8
macosx/English.lproj/PrefsWindow.nib/info.nib
generated
8
macosx/English.lproj/PrefsWindow.nib/info.nib
generated
|
@ -3,15 +3,15 @@
|
|||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBDocumentLocation</key>
|
||||
<string>18 87 356 240 0 0 1152 842 </string>
|
||||
<string>19 87 356 240 0 0 1152 842 </string>
|
||||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>153</key>
|
||||
<string>123 483 563 267 0 0 1152 842 </string>
|
||||
<string>294 445 563 267 0 0 1152 842 </string>
|
||||
<key>28</key>
|
||||
<string>294 434 563 290 0 0 1152 842 </string>
|
||||
<key>41</key>
|
||||
<string>294 420 563 317 0 0 1152 842 </string>
|
||||
<string>108 420 563 342 0 0 1152 842 </string>
|
||||
<key>66</key>
|
||||
<string>294 507 563 144 0 0 1152 842 </string>
|
||||
</dict>
|
||||
|
@ -23,7 +23,7 @@
|
|||
</array>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>153</integer>
|
||||
<integer>41</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>8L127</string>
|
||||
|
|
BIN
macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib
generated
BIN
macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -36,7 +36,7 @@
|
|||
NSToolbar * fToolbar;
|
||||
IBOutlet NSView * fGeneralView, * fTransfersView, * fBandwidthView, * fNetworkView;
|
||||
|
||||
IBOutlet NSPopUpButton * fFolderPopUp, * fImportFolderPopUp,
|
||||
IBOutlet NSPopUpButton * fFolderPopUp, * fIncompleteFolderPopUp, * fImportFolderPopUp,
|
||||
* fDownloadSoundPopUp, * fSeedingSoundPopUp;
|
||||
|
||||
NSArray * fSounds;
|
||||
|
@ -68,8 +68,9 @@
|
|||
|
||||
- (void) setCopyTorrents: (id) sender;
|
||||
|
||||
- (void) setDownloadLocation: (id) sender;
|
||||
- (void) folderSheetShow: (id) sender;
|
||||
- (void) setDownloadLocation: (id) sender;
|
||||
- (void) folderSheetShow: (id) sender;
|
||||
- (void) incompleteFolderSheetShow: (id) sender;
|
||||
|
||||
- (void) setPort: (id) sender;
|
||||
- (void) updatePortStatus;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
- (void) setPrefView: (id) sender;
|
||||
|
||||
- (void) folderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
|
||||
- (void) incompleteFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
|
||||
- (void) importFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
|
||||
|
||||
@end
|
||||
|
@ -396,6 +397,21 @@
|
|||
@selector(folderSheetClosed:returnCode:contextInfo:) contextInfo: nil];
|
||||
}
|
||||
|
||||
- (void) incompleteFolderSheetShow: (id) sender
|
||||
{
|
||||
NSOpenPanel * panel = [NSOpenPanel openPanel];
|
||||
|
||||
[panel setPrompt: @"Select"];
|
||||
[panel setAllowsMultipleSelection: NO];
|
||||
[panel setCanChooseFiles: NO];
|
||||
[panel setCanChooseDirectories: YES];
|
||||
[panel setCanCreateDirectories: YES];
|
||||
|
||||
[panel beginSheetForDirectory: nil file: nil types: nil
|
||||
modalForWindow: [self window] modalDelegate: self didEndSelector:
|
||||
@selector(incompleteFolderSheetClosed:returnCode:contextInfo:) contextInfo: nil];
|
||||
}
|
||||
|
||||
- (void) setAutoImport: (id) sender
|
||||
{
|
||||
if ([fDefaults boolForKey: @"AutoImport"])
|
||||
|
@ -508,6 +524,13 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void) incompleteFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
|
||||
{
|
||||
if (code == NSOKButton)
|
||||
[fDefaults setObject: [[openPanel filenames] objectAtIndex: 0] forKey: @"IncompleteDownloadFolder"];
|
||||
[fIncompleteFolderPopUp selectItemAtIndex: 0];
|
||||
}
|
||||
|
||||
- (void) importFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
|
||||
{
|
||||
if (code == NSOKButton)
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
BOOL fResumeOnWake;
|
||||
NSDate * fDate;
|
||||
|
||||
BOOL fUseIncompleteFolder;
|
||||
NSString * fDownloadFolder, * fIncompleteFolder;
|
||||
|
||||
BOOL fPrivateTorrent, fPublicTorrent;
|
||||
NSString * fPublicTorrentLocation;
|
||||
|
||||
|
|
|
@ -65,6 +65,9 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
|
||||
if (self)
|
||||
{
|
||||
fUseIncompleteFolder = [fDefaults boolForKey: @"UseIncompleteDownloadFolder"];
|
||||
fIncompleteFolder = [[fDefaults stringForKey: @"IncompleteDownloadFolder"] copy];
|
||||
|
||||
if (!fPublicTorrent)
|
||||
[self trashFile: path];
|
||||
}
|
||||
|
@ -85,9 +88,27 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
|
||||
if (self)
|
||||
{
|
||||
//download folders
|
||||
NSString * downloadFolder;
|
||||
if (!(downloadFolder = [history objectForKey: @"DownloadFolder"]))
|
||||
downloadFolder = [[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath];
|
||||
|
||||
NSNumber * useIncompleteFolder;
|
||||
if ((useIncompleteFolder = [history objectForKey: @"UseIncompleteFolder"]))
|
||||
{
|
||||
if ((fUseIncompleteFolder = [useIncompleteFolder boolValue]))
|
||||
{
|
||||
NSString * incompleteFolder;
|
||||
if (incompleteFolder = [history objectForKey: @"IncompleteFolder"])
|
||||
fIncompleteFolder = [incompleteFolder copy];
|
||||
else
|
||||
fIncompleteFolder = [[[fDefaults stringForKey: @"IncompleteDownloadFolder"]
|
||||
stringByExpandingTildeInPath] copy];
|
||||
}
|
||||
}
|
||||
else
|
||||
fUseIncompleteFolder = NO;
|
||||
|
||||
[self setDownloadFolder: downloadFolder];
|
||||
|
||||
NSString * paused;
|
||||
|
@ -105,14 +126,18 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
NSMutableDictionary * history = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithBool: fPrivateTorrent], @"PrivateCopy",
|
||||
[NSNumber numberWithBool: fPublicTorrent], @"PublicCopy",
|
||||
[self downloadFolder], @"DownloadFolder",
|
||||
fDownloadFolder, @"DownloadFolder",
|
||||
[NSNumber numberWithBool: fUseIncompleteFolder], @"UseIncompleteFolder",
|
||||
[self isActive] ? @"NO" : @"YES", @"Paused",
|
||||
[self date], @"Date",
|
||||
[NSNumber numberWithInt: fStopRatioSetting], @"StopRatioSetting",
|
||||
[NSNumber numberWithFloat: fRatioLimit], @"RatioLimit",
|
||||
[NSNumber numberWithBool: fWaitToStart], @"WaitToStart",
|
||||
[self orderValue], @"OrderValue", nil];
|
||||
|
||||
|
||||
if (fUseIncompleteFolder)
|
||||
[history setObject: fIncompleteFolder forKey: @"IncompleteFolder"];
|
||||
|
||||
if (fPrivateTorrent)
|
||||
[history setObject: [self hashString] forKey: @"TorrentHash"];
|
||||
|
||||
|
@ -128,6 +153,11 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
{
|
||||
tr_torrentClose(fLib, fHandle);
|
||||
|
||||
if (fDownloadFolder)
|
||||
[fDownloadFolder release];
|
||||
if (fIncompleteFolder)
|
||||
[fIncompleteFolder release];
|
||||
|
||||
if (fPublicTorrentLocation)
|
||||
[fPublicTorrentLocation release];
|
||||
|
||||
|
@ -151,7 +181,13 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
|
||||
- (void) setDownloadFolder: (NSString *) path
|
||||
{
|
||||
tr_torrentSetFolder(fHandle, [path UTF8String]);
|
||||
fDownloadFolder = [path copy];
|
||||
|
||||
if (!fUseIncompleteFolder || [[NSFileManager defaultManager] fileExistsAtPath:
|
||||
[path stringByAppendingPathComponent: [self name]]])
|
||||
tr_torrentSetFolder(fHandle, [path UTF8String]);
|
||||
else
|
||||
tr_torrentSetFolder(fHandle, [fIncompleteFolder UTF8String]);
|
||||
}
|
||||
|
||||
- (NSString *) downloadFolder
|
||||
|
@ -175,7 +211,19 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
|
||||
//notification when downloading finished
|
||||
if ([self justFinished])
|
||||
{
|
||||
//move file from incomplete folder to download folder
|
||||
if (fUseIncompleteFolder && ![[self downloadFolder] isEqualToString: fDownloadFolder])
|
||||
{
|
||||
tr_torrentStop(fHandle);
|
||||
if ([[NSFileManager defaultManager] movePath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]
|
||||
toPath: [fDownloadFolder stringByAppendingPathComponent: [self name]] handler: nil])
|
||||
tr_torrentSetFolder(fHandle, [fDownloadFolder UTF8String]);
|
||||
tr_torrentStart(fHandle);
|
||||
}
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self];
|
||||
}
|
||||
|
||||
//check to stop for ratio
|
||||
if ([self isSeeding] && ((fStopRatioSetting == RATIO_CHECK && [self ratio] >= fRatioLimit)
|
||||
|
|
Loading…
Add table
Reference in a new issue