zed/crates/auto_update
Vitaly Slobodin ca2eb275de
Unmount the auto-update disk image regardless of the auto-update status (#17019)
Closes #10782

In some cases, during the auto-update process,
the update can fail and leave a dangling disk image in macOS. If the
auto-update fails again, a new dangling mounted volume will be left
behind. To avoid polluting the system with these dangling mounted disk
images,
implement [the `Drop`
trait](https://doc.rust-lang.org/std/ops/trait.Drop.html) for the
`MacOSUnmounter` struct. This will ensure that the disk image
is unmounted when the `install_release_macos` function exits regardless
of its result.

## How to test this locally

Unfortunately, I was a bit too lazy to find a smarter way to test this,
so I simply commented out a bunch of lines to emulate the auto-update
process. To replicate the linked issue (#10782), you can apply the
attached patch. Build the Zed binary and run it. The auto-update should
fail, leaving the dangling mounted disk image in the system:

```shell
>diskutil list
/dev/disk5 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +220.6 MB   disk5
                                 Physical Store disk4s1
   1:                APFS Volume Zed                     190.6 MB   disk5s1
```

Run the Zed binary again to create another mounted disk image:

```shell
>diskutil list
/dev/disk5 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +220.6 MB   disk5
                                 Physical Store disk4s1
   1:                APFS Volume Zed                     190.6 MB   disk5s1

/dev/disk7 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +220.6 MB   disk7
                                 Physical Store disk6s1
   1:                APFS Volume Zed                     190.6 MB   disk7s1
```


[simulate_zed_autoupdate.patch](https://github.com/user-attachments/files/16787955/simulate_zed_autoupdate.patch)

Please let me know if the fix is good; otherwise, I am happy to
implement it differently. Thanks!

Release Notes:

- Fixed #10782
2024-08-28 21:15:38 -07:00
..
src Unmount the auto-update disk image regardless of the auto-update status (#17019) 2024-08-28 21:15:38 -07:00
Cargo.toml Update http crate name (#15041) 2024-07-23 15:01:05 -07:00
LICENSE-GPL chore: Change AGPL-licensed crates to GPL (except for collab) (#4231) 2024-01-24 00:26:58 +01:00