Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTX-5758: Fix for crontab scheduling new job on every activateAutoUpdate() function call. #228

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions coretex/cli/modules/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ def getExisting() -> List[str]:

def jobExists(script: str) -> bool:
existingLines = getExisting()
return any(line.endswith(script) for line in existingLines)
return any(script in line for line in existingLines)


def scheduleJob(scriptName: str) -> None:
existingLines = getExisting()
existingLines.append(f"*/30 * * * * {CONFIG_DIR / scriptName} >> {CONFIG_DIR}/logs/ctx_autoupdate.log 2>&1\n")
cronJob = f"*/30 * * * * {CONFIG_DIR / scriptName} >> {CONFIG_DIR}/logs/ctx_autoupdate.log 2>&1\n"
existingLines.append(cronJob)

tempCronFilePath = CONFIG_DIR / "temp.cron"
with tempCronFilePath.open("w") as tempCronFile:
Expand Down
2 changes: 1 addition & 1 deletion coretex/cli/modules/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def activateAutoUpdate() -> None:
updateScriptPath = DEFAULT_VENV_PATH.parent / UPDATE_SCRIPT_NAME
dumpScript(updateScriptPath)

if not jobExists(UPDATE_SCRIPT_NAME):
if not jobExists(str(updateScriptPath)):
scheduleJob(UPDATE_SCRIPT_NAME)


Expand Down
Loading