Skip to content

Commit

Permalink
Merge pull request #11521 from keymanapp/chore/windows/4038/clean-up-…
Browse files Browse the repository at this point in the history
…alpa-task

chore(windows): remove schedule task clean up introduced in 15.0 Alpha
  • Loading branch information
rc-swag authored May 24, 2024
2 parents 1e2507b + 080f265 commit b558c2b
Showing 1 changed file with 0 additions and 44 deletions.
44 changes: 0 additions & 44 deletions windows/src/desktop/kmshell/util/Keyman.System.KeymanStartTask.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ interface
TKeymanStartTask = class
private
class function GetTaskName: string;
class procedure CleanupAlphaTasks(pTaskFolder: ITaskFolder); static;
{$IF FALSE}
//Disabled to avoid hint during build; re-enable if wanting to
//re-establish the task model
Expand Down Expand Up @@ -115,15 +114,6 @@ class procedure TKeymanStartTask.CreateTask;
end;
end;

try
CleanupAlphaTasks(pTaskFolder);
except
on E:Exception do
begin
TKeymanSentryClient.ReportHandledException(E, 'Failed to cleanup alpha tasks');
end;
end;

try
// Create a new task
pTask := pService.NewTask(0);
Expand Down Expand Up @@ -228,8 +218,6 @@ class procedure TKeymanStartTask.DeleteTask;
end;
end;

CleanupAlphaTasks(pTaskFolder);

if pTaskFolder.GetTasks(0).Count = 0 then
begin
pTaskFolder := nil;
Expand Down Expand Up @@ -260,36 +248,4 @@ class procedure TKeymanStartTask.RecreateTask;
CreateTask;
end;

class procedure TKeymanStartTask.CleanupAlphaTasks(pTaskFolder: ITaskFolder);
var
tasks: IRegisteredTaskCollection;
i: Integer;
begin
// Cleanup earlier alpha-version tasks: we renamed the task to include the
// user's login name in build 14.0.194 of Keyman, so that multiple users could
// create the task on the same machine. It's not obvious, but the Tasks
// namespace is shared between all users -- non-admin users will not be able
// to see or overwrite tasks created by other users; they'd just get a
// (silent) access denied result.
try
tasks := pTaskFolder.GetTasks(0);
for i := 1 to tasks.Count do
if SameText(tasks.Item[i].Name, CTaskName) then
begin
tasks := nil;
pTaskFolder.DeleteTask(CTaskName, 0);
Exit;
end;
except
on E:EOleException do
begin
if (E.ErrorCode <> HResultFromWin32(ERROR_FILE_NOT_FOUND)) and
(E.ErrorCode <> HResultFromWin32(ERROR_ACCESS_DENIED)) then
// We ignore when the task doesn't exist, but report other errors
TKeymanSentryClient.ReportHandledException(E, 'Failed to delete task '+CTaskName);
end;
end;
end;


end.

0 comments on commit b558c2b

Please sign in to comment.