Skip to content

Comments

NXDRIVE-3133: End the running Drive task before attempting to install#6281

Open
S-Ghosh-Dev2 wants to merge 2 commits intomasterfrom
wip-NXDRIVE-3133-end-the-running-drive-task-before-attempting-to-install
Open

NXDRIVE-3133: End the running Drive task before attempting to install#6281
S-Ghosh-Dev2 wants to merge 2 commits intomasterfrom
wip-NXDRIVE-3133-end-the-running-drive-task-before-attempting-to-install

Conversation

@S-Ghosh-Dev2
Copy link
Collaborator

@S-Ghosh-Dev2 S-Ghosh-Dev2 commented Feb 18, 2026

Summary by Sourcery

Ensure the Windows installer safely stops any running Nuxeo Drive process before upgrading and simplifies cleanup of previous installations.

Bug Fixes:

  • Prevent installation failures caused by stale or locked application files when upgrading, including DLL load errors from previous versions.

Enhancements:

  • Disable the generic Inno Setup application-closing prompt in favor of a custom pre-install check that force-stops the Drive executable if needed.
  • Replace targeted deletion of specific legacy DLLs with full cleanup of the installation directory before copying new files.

Documentation:

  • Document NXDRIVE-3133 in the 6.1.0 changelog as ending the running Drive task before installation.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 18, 2026

Reviewer's Guide

Updates the Windows Inno Setup installer to proactively terminate the running Drive process before installation and to fully clean the install directory, plus documents the change in the 6.1.0 release notes.

Sequence diagram for Windows installer killing running Drive task before installation

sequenceDiagram
    actor User
    participant WindowsInstaller
    participant PrepareToInstall
    participant DriveProcess

    User->>WindowsInstaller: Start_installation
    WindowsInstaller->>PrepareToInstall: PrepareToInstall(NeedsRestart)
    PrepareToInstall->>PrepareToInstall: IsProcessRunning(MyAppExeName)?
    alt Drive_not_running
        PrepareToInstall-->>WindowsInstaller: ""
        WindowsInstaller->>WindowsInstaller: Proceed_with_installation
    else Drive_running
        PrepareToInstall->>DriveProcess: taskkill /F /IM MyAppExeName
        PrepareToInstall->>PrepareToInstall: Sleep(2000)
        PrepareToInstall->>PrepareToInstall: IsProcessRunning(MyAppExeName)?
        alt Kill_successful
            PrepareToInstall-->>WindowsInstaller: ""
            WindowsInstaller->>WindowsInstaller: Proceed_with_installation
        else Kill_failed
            PrepareToInstall-->>WindowsInstaller: Error_message_requesting_manual_close
            WindowsInstaller-->>User: Show_error_and_abort_installation
        end
    end

    WindowsInstaller->>WindowsInstaller: Delete_existing_files_in_app_dir
    WindowsInstaller->>WindowsInstaller: Install_new_files
Loading

Flow diagram for PrepareToInstall logic in the Windows installer

flowchart TD
    Start["PrepareToInstall called"] --> Init["Set Result to empty string"]
    Init --> CheckRunning["IsProcessRunning(MyAppExeName)?"]

    CheckRunning -->|No| ExitEarly["Exit function (no restart needed)"]
    ExitEarly --> End

    CheckRunning -->|Yes| KillProc["Exec taskkill /F /IM MyAppExeName"]
    KillProc --> Wait["Sleep 2000 ms"]
    Wait --> Recheck["IsProcessRunning(MyAppExeName)?"]

    Recheck -->|No| Success["Leave Result empty and continue installation"]
    Success --> End

    Recheck -->|Yes| Fail["Set Result to error message asking user to close app"]
    Fail --> End

    End["Return Result to installer"]
Loading

File-Level Changes

Change Details Files
Adjust installer behavior to avoid generic close-application prompts and instead handle Drive termination explicitly in script.
  • Disable the built-in CloseApplications prompt in Inno Setup and rely on custom logic to handle running processes
  • Add a PrepareToInstall hook that checks if the Drive executable is running and attempts to terminate it using taskkill
  • Add an IsProcessRunning helper using tasklist and find to detect whether the Drive process is still active
  • Display a user-facing message if the Drive process cannot be terminated automatically, instructing manual shutdown
tools/windows/setup-common.iss
Ensure a clean installation directory to prevent conflicts from stale binaries and DLLs.
  • Replace a long list of targeted InstallDelete entries for specific DLLs and subdirectories with a single wildcard deletion of all files and directories under the installation root
  • Keep high-level comment explaining the rationale as preventing conflicts like stale Qt-related DLL errors
tools/windows/setup-common.iss
Document the new behavior in the release notes.
  • Add NXDRIVE-3133 entry to the 6.1.0 changelog describing that Drive is ended before attempting installation
docs/changes/6.1.0.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • In PrepareToInstall, the comment // Force-kill the process on the early Exit is misleading (that path actually does nothing), which may confuse future maintainers; either remove or update the comment and consider explicitly documenting the intended control flow when the process is not running.
  • The IsProcessRunning/taskkill commands build shell arguments by concatenating the process name without quoting, which will break if {#MyAppExeName} ever contains spaces or special characters; it would be safer to wrap the process name in quotes and avoid relying on shell parsing where possible.
  • Changing [InstallDelete] to Name: "{app}\*" will delete everything under the install directory before upgrade; double‑check this path contains only application binaries and not user-specific or shared data, and if needed narrow the pattern to just the known runtime artifacts to minimize accidental deletion.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `PrepareToInstall`, the comment `// Force-kill the process` on the early `Exit` is misleading (that path actually does nothing), which may confuse future maintainers; either remove or update the comment and consider explicitly documenting the intended control flow when the process is not running.
- The `IsProcessRunning`/`taskkill` commands build shell arguments by concatenating the process name without quoting, which will break if `{#MyAppExeName}` ever contains spaces or special characters; it would be safer to wrap the process name in quotes and avoid relying on shell parsing where possible.
- Changing `[InstallDelete]` to `Name: "{app}\*"` will delete everything under the install directory before upgrade; double‑check this path contains only application binaries and not user-specific or shared data, and if needed narrow the pattern to just the known runtime artifacts to minimize accidental deletion.

## Individual Comments

### Comment 1
<location> `tools/windows/setup-common.iss:53` </location>
<code_context>
+; Delete everything inside the installation directory before installing new files.
+; This ensures no orphaned files from previous versions cause conflicts (e.g.,
+; "DLL load failed while importing QtCore" errors due to stale DLLs).
+Type: filesandordirs; Name: "{app}\*"


</code_context>

<issue_to_address>
**question (bug_risk):** Deleting everything under {app} on install can remove user-modified or runtime-generated files that were previously preserved.

Changing from targeted DLL cleanup to `Type: filesandordirs; Name: "{app}\*"` will now wipe everything under `{app}` on upgrade, including any user data, logs, or config placed there. Please either (a) confirm that `{app}` never holds user-touched data (and that it all lives elsewhere, e.g. `%APPDATA%`), or (b) explicitly exclude any user-data subdirectories/files from this cleanup to avoid accidental data loss.
</issue_to_address>

### Comment 2
<location> `docs/changes/6.1.0.md:28` </location>
<code_context>
 - [NXDRIVE-3108](https://hyland.atlassian.net/browse/NXDRIVE-3108): Fix MacOS release version checking on Github
 - [NXDRIVE-3110](https://hyland.atlassian.net/browse/NXDRIVE-3110): Update timeout on macOS
 - [NXDRIVE-3122](https://hyland.atlassian.net/browse/NXDRIVE-3122): Fix upgrade issue from 5.4.0 to latest
</code_context>

<issue_to_address>
**suggestion (typo):** Consider correcting "MacOS" to "macOS" for consistency and accuracy.

Here, "MacOS" should match the "macOS" spelling used below to stay consistent with Apple’s official naming.

```suggestion
- [NXDRIVE-3108](https://hyland.atlassian.net/browse/NXDRIVE-3108): Fix macOS release version checking on Github
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses NXDRIVE-3133 by ensuring that the running Nuxeo Drive process is terminated before installation proceeds. The changes replace Inno Setup's built-in application closure mechanism with a custom implementation that forcefully kills ndrive.exe if it's running.

Changes:

  • Disabled Inno Setup's automatic "close applications" prompt and replaced it with custom process termination logic
  • Simplified the InstallDelete section to remove all files in the installation directory (replacing specific file patterns)
  • Added two new functions: IsProcessRunning to check if ndrive.exe is active, and PrepareToInstall to terminate the process before installation

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tools/windows/setup-common.iss Implements custom process termination logic and simplified cleanup, disables built-in close applications prompt
docs/changes/6.1.0.md Adds changelog entry for NXDRIVE-3133

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +143 to +145
Exit; // Force-kill the process

Exec('taskkill', '/F /IM {#MyAppExeName}', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic in this function is inverted. The comment says "Force-kill the process" but it actually exits early when the process is NOT running. This means when the process IS running (line 142 evaluates to false), the code continues to lines 145-150 to kill it. However, the comment placement makes it confusing and suggests incorrect logic. The early exit should occur when the process is already stopped (not running), which is the correct behavior but the comment is misleading.

Suggested change
Exit; // Force-kill the process
Exec('taskkill', '/F /IM {#MyAppExeName}', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exit; // Process is not running; nothing to do
Exec('taskkill', '/F /IM {#MyAppExeName}', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); // Force-kill the process

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant