Skip to content

Commit

Permalink
fix(core): don't disable the current script if we aren't doing anything
Browse files Browse the repository at this point in the history
  • Loading branch information
extrafu committed Nov 7, 2019
1 parent ac91a30 commit 2bc24ec
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions SoObjects/SOGo/SOGoSieveManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,7 @@ - (BOOL) updateFiltersForAccount: (SOGoMailAccount *) theAccount
v = [self _extractRequirementsFromContent: content
intoArray: req];
[script insertString: v atIndex: 0];
b = YES;
}
}

Expand All @@ -1101,38 +1102,38 @@ - (BOOL) updateFiltersForAccount: (SOGoMailAccount *) theAccount
header = [NSString stringWithFormat: @"require [\"%@\"];\r\n",
[[req uniqueObjects] componentsJoinedByString: @"\",\""]];
[script insertString: header atIndex: 0];
b = YES;
}


/* We ensure to deactive the current active script since it could prevent
its deletion from the server. */
result = [client setActiveScript: @""];
// We delete the existing Sieve script
result = [client deleteScript: sieveScriptName];

if (![[result valueForKey:@"result"] boolValue]) {
[self logWithFormat: @"WARNING: Could not delete Sieve script - continuing...: %@", result];
}

// We put and activate the script only if we actually have a script
// that does something...
if (b && [script length])
{
result = [client setActiveScript: @""];
// We delete the existing Sieve script
result = [client deleteScript: sieveScriptName];

if (![[result valueForKey:@"result"] boolValue])
[self logWithFormat: @"WARNING: Could not delete Sieve script - continuing...: %@", result];

result = [client putScript: sieveScriptName script: script];

if (![[result valueForKey:@"result"] boolValue]) {
[self logWithFormat: @"Could not upload Sieve script: %@", result];
[client closeConnection];
return NO;
}
if (![[result valueForKey:@"result"] boolValue])
{
[self logWithFormat: @"Could not upload Sieve script: %@", result];
[client closeConnection];
return NO;
}

result = [client setActiveScript: sieveScriptName];
if (![[result valueForKey:@"result"] boolValue]) {
[self logWithFormat: @"Could not enable Sieve script: %@", result];
[client closeConnection];
return NO;
}
}
if (![[result valueForKey:@"result"] boolValue])
{
[self logWithFormat: @"Could not enable Sieve script: %@", result];
[client closeConnection];
return NO;
}
}

[client closeConnection];
return YES;
Expand Down

0 comments on commit 2bc24ec

Please sign in to comment.