{"record":{"id":"b85d5d844fa0f23b","repo":"XX-net/XX-Net","slug":"try-to-delect-current-version","errorCode":null,"errorMessage":"try to delect current version.","messagePattern":"try to delect current version\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"code/default/launcher/update_from_github.py","lineNumber":351,"sourceCode":"    files_in_code_path = os.listdir(code_path)\n    local_versions = []\n    for name in files_in_code_path:\n        if os.path.isdir(os.path.join(code_path, name)):\n            v = get_folder_version(name)\n            if v:\n                local_versions.append([v, name])\n    local_versions.sort(key=lambda s: list(map(int, s[0].split('.'))), reverse=True)\n    return local_versions\n\n\ndef get_current_version_dir():\n    current_dir = os.path.split(root_path)[-1]\n    return current_dir\n\n\ndef del_version(version):\n    if version == get_current_version_dir():\n        xlog.warn(\"try to delect current version.\")\n        return False\n\n    try:\n        shutil.rmtree(os.path.join(top_path, \"code\", version))\n        return True\n    except Exception as e:\n        xlog.warn(\"deleting fail: %s\", e)\n        return False\n\n\ndef update_current_version(version):\n    start_script = os.path.join(top_path, \"code\", version, \"launcher\", \"start.py\")\n    if not os.path.isfile(start_script):\n        xlog.warn(\"set version %s not exist\", version)\n        return False\n\n    current_version_file = os.path.join(top_path, \"code\", \"version.txt\")\n    with open(current_version_file, \"w\") as fd:","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/launcher/update_from_github.py#L333-L369","documentation":"del_version(version) refuses to delete the currently running version directory: it compares against get_current_version_dir() (the dirname containing launcher) and returns False if they match, to avoid deleting the live install.","triggerScenarios":"Any call to del_version with the version currently active (e.g. web UI cleanup attempting to remove the running build).","commonSituations":"User selects the running version in the version manager to delete; version.txt and directory naming out of sync after a manual copy of the code tree.","solutions":["Switch/update to another version first, then delete the old one.","If the check misfires because the install was moved, fix the directory layout so the running launcher lives under code/<current-version>/.","Refresh the web UI so the current-version marker is up to date."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if version == get_current_version_dir():\n    raise ValueError('refusing to delete running version %s' % version)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Update to a new version before deleting the old one.","Never bypass the current-version guard.","Confirm the target dir layout matches code/<version>/."],"tags":["self-update","version-management","safety-check"],"backgroundTag":"delete-current-version-blocked","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}