Skip to content

Fix cross-device link error in legacy storage#112

Merged
babarot merged 1 commit intomainfrom
babarot/fix-legacy-cross-device-move
Mar 20, 2026
Merged

Fix cross-device link error in legacy storage#112
babarot merged 1 commit intomainfrom
babarot/fix-legacy-cross-device-move

Conversation

@babarot
Copy link
Copy Markdown
Owner

@babarot babarot commented Mar 20, 2026

Summary

Fix invalid cross-device link error when using legacy storage with a trash directory on a different filesystem (e.g. NTFS mounted drive).

Background

Reported in Issue #104. When gomi_dir is set to a path on a different filesystem (e.g. /media/archive/Trash on NTFS while home is on ext4), the Put operation fails because os.Rename cannot move files across device boundaries. The fs.Move utility already supports fallback copy-and-delete for this scenario, but legacy storage was calling it with fallbackCopy: false.

The XDG storage already handles this correctly by passing s.config.HomeFallback to fs.Move.

Changes

  • legacy/storage.go: Change fs.Move calls from fallbackCopy: false to true in three places:
    • Put: moving file to trash
    • Put rollback: moving file back on history save failure
    • Restore: moving file from trash to original location

Closes #104

Enable fallback copy in fs.Move calls for legacy storage put,
restore, and rollback operations. Previously these used rename-only
mode which fails across different filesystems (e.g. NTFS).

Closes #104
@babarot babarot added the kind/bug A bug; unintended behavior label Mar 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Code Metrics Report

main (a985806) #112 (c2ff195) +/-
Coverage 50.0% 50.0% 0.0%
Code to Test Ratio 1:0.8 1:0.8 0.0
Test Execution Time 2s 2s 0s
Details
  |                     | main (a985806) | #112 (c2ff195) | +/-  |
  |---------------------|----------------|----------------|------|
  | Coverage            |          50.0% |          50.0% | 0.0% |
  |   Files             |             23 |             23 |    0 |
  |   Lines             |           1087 |           1087 |    0 |
  |   Covered           |            544 |            544 |    0 |
  | Code to Test Ratio  |          1:0.8 |          1:0.8 |  0.0 |
  |   Code              |           2713 |           2713 |    0 |
  |   Test              |           2321 |           2321 |    0 |
  | Test Execution Time |             2s |             2s |   0s |

Code coverage of files in pull request scope (0.0% β†’ 0.0%)

Files Coverage +/- Status
internal/trash/legacy/storage.go 0.0% 0.0% modified

Reported by octocov

@babarot babarot marked this pull request as ready for review March 20, 2026 09:13
@babarot babarot merged commit 7c07e4c into main Mar 20, 2026
5 checks passed
@babarot babarot deleted the babarot/fix-legacy-cross-device-move branch March 20, 2026 09:13
@github-actions github-actions bot mentioned this pull request Mar 20, 2026
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Mar 25, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [babarot/gomi](https://github.com/babarot/gomi) | patch | `v1.6.2` β†’ `v1.6.3` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>babarot/gomi (babarot/gomi)</summary>

### [`v1.6.3`](https://github.com/babarot/gomi/blob/HEAD/CHANGELOG.md#v163---2026-03-20)

[Compare Source](babarot/gomi@v1.6.2...v1.6.3)

##### Bug fixes

- Fix files with dollar signs in names being incorrectly expanded by [@&#8203;babarot](https://github.com/babarot) in [#&#8203;111](babarot/gomi#111)
- Fix cross-device link error in legacy storage by [@&#8203;babarot](https://github.com/babarot) in [#&#8203;112](babarot/gomi#112)

##### Improvements

- Fix empty files being excluded from restore list by [@&#8203;babarot](https://github.com/babarot) in [#&#8203;110](babarot/gomi#110)
- Fix gomi\_dir being ignored when strategy is auto by [@&#8203;babarot](https://github.com/babarot) in [#&#8203;113](babarot/gomi#113)
- Fix colors invisible on light terminal backgrounds by [@&#8203;babarot](https://github.com/babarot) in [#&#8203;114](babarot/gomi#114)

</details>

---

### Configuration

πŸ“… **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

β™» **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

πŸ”• **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My44Ny4xIiwidXBkYXRlZEluVmVyIjoiNDMuODcuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6OnBhdGNoIl19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug A bug; unintended behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot move to trash: NTFS

1 participant