Skip to content

Commit

Permalink
fix(tool): fix error handling when updating Sieve script
Browse files Browse the repository at this point in the history
  • Loading branch information
cgx committed Dec 19, 2019
1 parent 4ed2c72 commit d6d33f9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
11 changes: 9 additions & 2 deletions Tools/SOGoToolRestore.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SOGoToolRestore.m - this file is part of SOGo
*
* Copyright (C) 2009-2015 Inverse inc.
* Copyright (C) 2009-2019 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -614,6 +614,7 @@ - (BOOL) listRestorableFolders: (NSDictionary *) userRecord
- (BOOL) _updateSieveScripsForLogin: (NSString *) theLogin
{
/* credentials file handling */
NSException *error;
NSString *credsFilename, *authname=nil, *authpwd=nil;
SOGoCredentialsFile *cf;
SOGoUser *user;
Expand Down Expand Up @@ -650,7 +651,13 @@ - (BOOL) _updateSieveScripsForLogin: (NSString *) theLogin
account = [folder lookupName: @"0" inContext: localContext acquire: NO];
[account setContext: localContext];

return [account updateFiltersWithUsername: authname andPassword: authpwd];
error = [account updateFiltersWithUsername: authname
andPassword: authpwd
forceActivation: NO];
if (error)
return NO;

return YES;
}

- (BOOL) restoreUserPreferencesFromUserRecord: (NSDictionary *) userRecord
Expand Down
8 changes: 5 additions & 3 deletions Tools/SOGoToolUpdateAutoReply.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SOGoToolUpdateAutoReply.m - this file is part of SOGo
*
* Copyright (C) 2011-2016 Inverse inc.
* Copyright (C) 2011-2019 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -81,6 +81,7 @@ - (BOOL) updateAutoReplyForLogin: (NSString *) theLogin
SOGoUserDefaults *userDefaults;
SOGoUser *user;
BOOL result;
NSException *error;

user = [SOGoUser userWithLogin: theLogin];

Expand Down Expand Up @@ -127,10 +128,10 @@ - (BOOL) updateAutoReplyForLogin: (NSString *) theLogin
account = [folder lookupName: @"0" inContext: localContext acquire: NO];
[account setContext: localContext];

result = [account updateFiltersWithUsername: theUsername
error = [account updateFiltersWithUsername: theUsername
andPassword: thePassword
forceActivation: NO];
if (!result)
if (error)
{
// Can't update Sieve script -- Reactivate auto-reply
if (disabling)
Expand All @@ -139,6 +140,7 @@ - (BOOL) updateAutoReplyForLogin: (NSString *) theLogin
[vacationOptions setObject: [NSNumber numberWithBool: YES] forKey: @"startDateEnabled"];
[userDefaults setVacationOptions: vacationOptions];
[userDefaults synchronize];
result = NO;
}
}

Expand Down
9 changes: 7 additions & 2 deletions Tools/SOGoToolUserPreferences.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SOGoToolUserPreferences.m - this file is part of SOGo
*
* Copyright (C) 2011-2017 Inverse inc.
* Copyright (C) 2011-2019 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -122,6 +122,7 @@ - (BOOL) _updateSieveScripsForkey: (NSString *) theKey
}

/* update sieve script */
NSException *error;
SOGoUser *user;
SOGoUserFolder *home;
SOGoMailAccounts *folder;
Expand All @@ -141,7 +142,11 @@ - (BOOL) _updateSieveScripsForkey: (NSString *) theKey
account = [folder lookupName: @"0" inContext: localContext acquire: NO];
[account setContext: localContext];

return [account updateFiltersWithUsername: authname andPassword: authpwd];
error = [account updateFiltersWithUsername: authname
andPassword: authpwd
forceActivation: NO];
if (error)
return NO;
}

return YES;
Expand Down

0 comments on commit d6d33f9

Please sign in to comment.