Skip to content

Commit

Permalink
chore(windows): remove cleanup-alpha-tasks
Browse files Browse the repository at this point in the history
Remove the CleanupAlphaTasks that was specific to task
schedules created it for 15.0 alpha. Scheduled tasks naming
was changed to include a user name in the task. The clean up
function was to make sure the previous named tasks were removed.
Now there should be no 15.0 alpha users it can be removed.
  • Loading branch information
rc-swag committed May 23, 2024
1 parent 2772b8c commit 080f265
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 080f265

Please sign in to comment.