1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2024-11-04 15:29:02 +00:00

Re-implemented the fix for utf-8 lookup error during auto-update in a more graceful way.

This commit is contained in:
Virgil Dupras 2010-02-05 16:51:00 +01:00
parent a570406ac8
commit 9ca8a199c0
10 changed files with 56 additions and 46 deletions

View File

@ -11,6 +11,7 @@ http://www.hardcoded.net/licenses/hs_license
#import "PyDupeGuru.h" #import "PyDupeGuru.h"
#import "ResultWindow.h" #import "ResultWindow.h"
#import "DetailsPanel.h" #import "DetailsPanel.h"
#import "DirectoryPanel.h"
@interface AppDelegateBase : NSObject @interface AppDelegateBase : NSObject
{ {
@ -19,11 +20,15 @@ http://www.hardcoded.net/licenses/hs_license
IBOutlet NSMenuItem *unlockMenuItem; IBOutlet NSMenuItem *unlockMenuItem;
IBOutlet ResultWindowBase *result; IBOutlet ResultWindowBase *result;
DirectoryPanelBase *_directoryPanel;
DetailsPanelBase *_detailsPanel; DetailsPanelBase *_detailsPanel;
BOOL _savedResults;
} }
- (IBAction)unlockApp:(id)sender; - (IBAction)unlockApp:(id)sender;
- (PyDupeGuruBase *)py; - (PyDupeGuruBase *)py;
- (RecentDirectories *)recentDirectories; - (RecentDirectories *)recentDirectories;
- (DirectoryPanelBase *)directoryPanel; // Virtual
- (DetailsPanelBase *)detailsPanel; // Virtual - (DetailsPanelBase *)detailsPanel; // Virtual
- (void)saveResults;
@end @end

View File

@ -11,6 +11,7 @@ http://www.hardcoded.net/licenses/hs_license
#import "RegistrationInterface.h" #import "RegistrationInterface.h"
#import "Utils.h" #import "Utils.h"
#import "Consts.h" #import "Consts.h"
#import <Sparkle/SUUpdater.h>
@implementation AppDelegateBase @implementation AppDelegateBase
- (IBAction)unlockApp:(id)sender - (IBAction)unlockApp:(id)sender
@ -28,8 +29,19 @@ http://www.hardcoded.net/licenses/hs_license
- (PyDupeGuruBase *)py { return py; } - (PyDupeGuruBase *)py { return py; }
- (RecentDirectories *)recentDirectories { return recentDirectories; } - (RecentDirectories *)recentDirectories { return recentDirectories; }
- (DirectoryPanelBase *)directoryPanel {return nil; } // Virtual
- (DetailsPanelBase *)detailsPanel { return nil; } // Virtual - (DetailsPanelBase *)detailsPanel { return nil; } // Virtual
- (void)saveResults
{
if (_savedResults) {
return;
}
[py saveIgnoreList];
[py saveResults];
_savedResults = YES;
}
/* Delegate */ /* Delegate */
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{ {
@ -48,6 +60,7 @@ http://www.hardcoded.net/licenses/hs_license
//Restore results //Restore results
[py loadIgnoreList]; [py loadIgnoreList];
[py loadResults]; [py loadResults];
_savedResults = NO;
} }
- (void)applicationWillBecomeActive:(NSNotification *)aNotification - (void)applicationWillBecomeActive:(NSNotification *)aNotification
@ -61,8 +74,7 @@ http://www.hardcoded.net/licenses/hs_license
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
[ud setObject: [result getColumnsOrder] forKey:@"columnsOrder"]; [ud setObject: [result getColumnsOrder] forKey:@"columnsOrder"];
[ud setObject: [result getColumnsWidth] forKey:@"columnsWidth"]; [ud setObject: [result getColumnsWidth] forKey:@"columnsWidth"];
[py saveIgnoreList]; [self saveResults];
[py saveResults];
NSInteger sc = [ud integerForKey:@"sessionCountSinceLastIgnorePurge"]; NSInteger sc = [ud integerForKey:@"sessionCountSinceLastIgnorePurge"];
if (sc >= 10) if (sc >= 10)
{ {
@ -81,4 +93,14 @@ http://www.hardcoded.net/licenses/hs_license
{ {
[[self directoryPanel] addDirectory:directory]; [[self directoryPanel] addDirectory:directory];
} }
/* SUUpdater delegate */
- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)update untilInvoking:(NSInvocation *)invocation;
{
/* If results aren't saved now, we might get a weird utf-8 lookup error when saving later.
**/
[self saveResults];
return NO;
}
@end @end

View File

@ -2,10 +2,10 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10"> <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data> <data>
<int key="IBDocument.SystemTarget">1050</int> <int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">10B504</string> <string key="IBDocument.SystemVersion">10C540</string>
<string key="IBDocument.InterfaceBuilderVersion">740</string> <string key="IBDocument.InterfaceBuilderVersion">740</string>
<string key="IBDocument.AppKitVersion">1038.2</string> <string key="IBDocument.AppKitVersion">1038.25</string>
<string key="IBDocument.HIToolboxVersion">437.00</string> <string key="IBDocument.HIToolboxVersion">458.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions"> <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">740</string> <string key="NS.object.0">740</string>
@ -83,11 +83,9 @@
<string key="NSToolbarItemPaletteLabel">Power Marker</string> <string key="NSToolbarItemPaletteLabel">Power Marker</string>
<nil key="NSToolbarItemToolTip"/> <nil key="NSToolbarItemToolTip"/>
<object class="NSSegmentedControl" key="NSToolbarItemView" id="35398541"> <object class="NSSegmentedControl" key="NSToolbarItemView" id="35398541">
<reference key="NSNextResponder"/> <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int> <int key="NSvFlags">256</int>
<string key="NSFrame">{{7, 14}, {67, 24}}</string> <string key="NSFrame">{{7, 14}, {67, 24}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
<object class="NSSegmentedCell" key="NSCell" id="431579725"> <object class="NSSegmentedCell" key="NSCell" id="431579725">
<int key="NSCellFlags">67239424</int> <int key="NSCellFlags">67239424</int>
@ -178,11 +176,9 @@
<string key="NSToolbarItemPaletteLabel">Filter</string> <string key="NSToolbarItemPaletteLabel">Filter</string>
<nil key="NSToolbarItemToolTip"/> <nil key="NSToolbarItemToolTip"/>
<object class="NSSearchField" key="NSToolbarItemView" id="1013657232"> <object class="NSSearchField" key="NSToolbarItemView" id="1013657232">
<reference key="NSNextResponder"/> <nil key="NSNextResponder"/>
<int key="NSvFlags">258</int> <int key="NSvFlags">258</int>
<string key="NSFrame">{{0, 14}, {81, 22}}</string> <string key="NSFrame">{{0, 14}, {81, 22}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
<object class="NSSearchFieldCell" key="NSCell" id="484816507"> <object class="NSSearchFieldCell" key="NSCell" id="484816507">
<int key="NSCellFlags">343014976</int> <int key="NSCellFlags">343014976</int>
@ -324,11 +320,9 @@
<string key="NSToolbarItemPaletteLabel">Action</string> <string key="NSToolbarItemPaletteLabel">Action</string>
<nil key="NSToolbarItemToolTip"/> <nil key="NSToolbarItemToolTip"/>
<object class="NSPopUpButton" key="NSToolbarItemView" id="165812138"> <object class="NSPopUpButton" key="NSToolbarItemView" id="165812138">
<reference key="NSNextResponder"/> <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int> <int key="NSvFlags">256</int>
<string key="NSFrame">{{0, 14}, {58, 26}}</string> <string key="NSFrame">{{0, 14}, {58, 26}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
<object class="NSPopUpButtonCell" key="NSCell" id="436420677"> <object class="NSPopUpButtonCell" key="NSCell" id="436420677">
<int key="NSCellFlags">-2076049856</int> <int key="NSCellFlags">-2076049856</int>
@ -531,11 +525,9 @@
<string key="NSToolbarItemPaletteLabel">Delta Values</string> <string key="NSToolbarItemPaletteLabel">Delta Values</string>
<nil key="NSToolbarItemToolTip"/> <nil key="NSToolbarItemToolTip"/>
<object class="NSSegmentedControl" key="NSToolbarItemView" id="311230297"> <object class="NSSegmentedControl" key="NSToolbarItemView" id="311230297">
<reference key="NSNextResponder"/> <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int> <int key="NSvFlags">256</int>
<string key="NSFrame">{{4, 14}, {67, 24}}</string> <string key="NSFrame">{{4, 14}, {67, 24}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
<object class="NSSegmentedCell" key="NSCell" id="211272396"> <object class="NSSegmentedCell" key="NSCell" id="211272396">
<int key="NSCellFlags">67239424</int> <int key="NSCellFlags">67239424</int>
@ -2227,6 +2219,14 @@
</object> </object>
<int key="connectionID">1174</int> <int key="connectionID">1174</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="23220930"/>
<reference key="destination" ref="91622651"/>
</object>
<int key="connectionID">1175</int>
</object>
</object> </object>
<object class="IBMutableOrderedSet" key="objectRecords"> <object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects"> <object class="NSArray" key="orderedObjects">
@ -3584,7 +3584,7 @@
</object> </object>
</object> </object>
<nil key="sourceID"/> <nil key="sourceID"/>
<int key="maxID">1174</int> <int key="maxID">1175</int>
</object> </object>
<object class="IBClassDescriber" key="IBDocument.Classes"> <object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions"> <object class="NSMutableArray" key="referencedPartialClassDescriptions">

View File

@ -9,16 +9,11 @@ http://www.hardcoded.net/licenses/hs_license
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "../base/AppDelegate.h" #import "../base/AppDelegate.h"
#import "ResultWindow.h" #import "ResultWindow.h"
#import "DirectoryPanel.h"
#import "PyDupeGuru.h" #import "PyDupeGuru.h"
@interface AppDelegate : AppDelegateBase @interface AppDelegate : AppDelegateBase {}
{
DirectoryPanel *_directoryPanel;
}
- (IBAction)openWebsite:(id)sender; - (IBAction)openWebsite:(id)sender;
- (IBAction)toggleDirectories:(id)sender; - (IBAction)toggleDirectories:(id)sender;
- (DirectoryPanel *)directoryPanel;
- (PyDupeGuru *)py; - (PyDupeGuru *)py;
@end @end

View File

@ -13,6 +13,7 @@ http://www.hardcoded.net/licenses/hs_license
#import "../../cocoalib/ValueTransformers.h" #import "../../cocoalib/ValueTransformers.h"
#import "../../cocoalib/Dialogs.h" #import "../../cocoalib/Dialogs.h"
#import "DetailsPanel.h" #import "DetailsPanel.h"
#import "DirectoryPanel.h"
#import "Consts.h" #import "Consts.h"
@implementation AppDelegate @implementation AppDelegate
@ -73,7 +74,7 @@ http://www.hardcoded.net/licenses/hs_license
return _detailsPanel; return _detailsPanel;
} }
- (DirectoryPanel *)directoryPanel - (DirectoryPanelBase *)directoryPanel
{ {
if (!_directoryPanel) if (!_directoryPanel)
_directoryPanel = [[DirectoryPanel alloc] initWithParentApp:self]; _directoryPanel = [[DirectoryPanel alloc] initWithParentApp:self];

View File

@ -8,16 +8,11 @@ http://www.hardcoded.net/licenses/hs_license
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "../base/AppDelegate.h" #import "../base/AppDelegate.h"
#import "DirectoryPanel.h"
#import "PyDupeGuru.h" #import "PyDupeGuru.h"
@interface AppDelegate : AppDelegateBase @interface AppDelegate : AppDelegateBase {}
{
DirectoryPanel *_directoryPanel;
}
- (IBAction)openWebsite:(id)sender; - (IBAction)openWebsite:(id)sender;
- (IBAction)toggleDirectories:(id)sender; - (IBAction)toggleDirectories:(id)sender;
- (DirectoryPanel *)directoryPanel;
- (PyDupeGuru *)py; - (PyDupeGuru *)py;
@end @end

View File

@ -13,6 +13,7 @@ http://www.hardcoded.net/licenses/hs_license
#import "ValueTransformers.h" #import "ValueTransformers.h"
#import "Consts.h" #import "Consts.h"
#import "DetailsPanel.h" #import "DetailsPanel.h"
#import "DirectoryPanel.h"
@implementation AppDelegate @implementation AppDelegate
+ (void)initialize + (void)initialize
@ -57,7 +58,7 @@ http://www.hardcoded.net/licenses/hs_license
[[self directoryPanel] toggleVisible:sender]; [[self directoryPanel] toggleVisible:sender];
} }
- (DirectoryPanel *)directoryPanel - (DirectoryPanelBase *)directoryPanel
{ {
if (!_directoryPanel) if (!_directoryPanel)
_directoryPanel = [[DirectoryPanel alloc] initWithParentApp:self]; _directoryPanel = [[DirectoryPanel alloc] initWithParentApp:self];

View File

@ -8,16 +8,11 @@ http://www.hardcoded.net/licenses/hs_license
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "../base/AppDelegate.h" #import "../base/AppDelegate.h"
#import "DirectoryPanel.h"
#import "PyDupeGuru.h" #import "PyDupeGuru.h"
@interface AppDelegate : AppDelegateBase @interface AppDelegate : AppDelegateBase {}
{
DirectoryPanel *_directoryPanel;
}
- (IBAction)openWebsite:(id)sender; - (IBAction)openWebsite:(id)sender;
- (IBAction)toggleDirectories:(id)sender; - (IBAction)toggleDirectories:(id)sender;
- (DirectoryPanel *)directoryPanel;
- (PyDupeGuru *)py; - (PyDupeGuru *)py;
@end @end

View File

@ -12,6 +12,7 @@ http://www.hardcoded.net/licenses/hs_license
#import "../../cocoalib/Utils.h" #import "../../cocoalib/Utils.h"
#import "../../cocoalib/ValueTransformers.h" #import "../../cocoalib/ValueTransformers.h"
#import "DetailsPanel.h" #import "DetailsPanel.h"
#import "DirectoryPanel.h"
#import "Consts.h" #import "Consts.h"
@implementation AppDelegate @implementation AppDelegate
@ -56,7 +57,7 @@ http://www.hardcoded.net/licenses/hs_license
[[self directoryPanel] toggleVisible:sender]; [[self directoryPanel] toggleVisible:sender];
} }
- (DirectoryPanel *)directoryPanel - (DirectoryPanelBase *)directoryPanel
{ {
if (!_directoryPanel) if (!_directoryPanel)
_directoryPanel = [[DirectoryPanel alloc] initWithParentApp:self]; _directoryPanel = [[DirectoryPanel alloc] initWithParentApp:self];

View File

@ -212,13 +212,8 @@ class DupeGuru(RegistrableApplication):
changed_groups.add(g) changed_groups.add(g)
def save(self): def save(self):
try:
self.directories.save_to_file(op.join(self.appdata, 'last_directories.xml')) self.directories.save_to_file(op.join(self.appdata, 'last_directories.xml'))
self.results.save_to_xml(op.join(self.appdata, 'last_results.xml')) self.results.save_to_xml(op.join(self.appdata, 'last_results.xml'))
except LookupError:
# This is that weird issue from #39 that sometimes happens when auto-updating with
# Sparkle. Just ignore it.
pass
def save_ignore_list(self): def save_ignore_list(self):
p = op.join(self.appdata, 'ignore_list.xml') p = op.join(self.appdata, 'ignore_list.xml')