mirror of
https://github.com/transmission/transmission
synced 2025-02-02 20:43:51 +00:00
save transfer info in a file in application support rather than into the preference file
This commit is contained in:
parent
84fad8a25f
commit
1f31ecce39
2 changed files with 34 additions and 12 deletions
|
@ -205,6 +205,8 @@
|
|||
|
||||
- (void) prepareForUpdate: (NSNotification *) notification;
|
||||
|
||||
- (NSString *) applicationSupportFolder;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
|
|
@ -281,16 +281,31 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
else
|
||||
NSLog(@"Could not IORegisterForSystemPower");
|
||||
|
||||
//load torrents from history
|
||||
Torrent * torrent;
|
||||
NSDictionary * historyItem;
|
||||
NSEnumerator * enumerator = [[fDefaults arrayForKey: @"History"] objectEnumerator];
|
||||
while ((historyItem = [enumerator nextObject]))
|
||||
if ((torrent = [[Torrent alloc] initWithHistory: historyItem lib: fLib]))
|
||||
{
|
||||
[fTorrents addObject: torrent];
|
||||
[torrent release];
|
||||
}
|
||||
//load previous transfers
|
||||
NSLog([self applicationSupportFolder]);
|
||||
NSArray * history = [[NSArray alloc] initWithContentsOfFile: [[self applicationSupportFolder]
|
||||
stringByAppendingPathComponent: @"Transfers.plist"]];
|
||||
|
||||
//old version saved transfer info in prefs file
|
||||
if (!history)
|
||||
if ((history = [fDefaults arrayForKey: @"History"]))
|
||||
[history retain];
|
||||
[fDefaults removeObjectForKey: @"History"];
|
||||
|
||||
if (history)
|
||||
{
|
||||
Torrent * torrent;
|
||||
NSDictionary * historyItem;
|
||||
NSEnumerator * enumerator = [history objectEnumerator];
|
||||
while ((historyItem = [enumerator nextObject]))
|
||||
if ((torrent = [[Torrent alloc] initWithHistory: historyItem lib: fLib]))
|
||||
{
|
||||
[fTorrents addObject: torrent];
|
||||
[torrent release];
|
||||
}
|
||||
|
||||
[history release];
|
||||
}
|
||||
|
||||
//set sort
|
||||
fSortType = [[fDefaults stringForKey: @"Sort"] retain];
|
||||
|
@ -1359,8 +1374,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
while ((torrent = [enumerator nextObject]))
|
||||
[history addObject: [torrent history]];
|
||||
|
||||
[fDefaults setObject: history forKey: @"History"];
|
||||
[fDefaults synchronize];
|
||||
[history writeToFile: [[self applicationSupportFolder] stringByAppendingPathComponent: @"Transfers.plist"] atomically: YES];
|
||||
}
|
||||
|
||||
- (void) sortTorrents
|
||||
|
@ -2785,4 +2799,10 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
[[NSWorkspace sharedWorkspace] selectFile: location inFileViewerRootedAtPath: nil];
|
||||
}
|
||||
|
||||
- (NSString *) applicationSupportFolder
|
||||
{
|
||||
return [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) objectAtIndex: 0]
|
||||
stringByAppendingPathComponent: [[NSProcessInfo processInfo] processName]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue