mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-25 16:55:59 +03:00
[PR #5049] [MERGED] fix(desktop): verbatim path handling in disk resolution #5031
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#5031
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/5049
Author: @CuriousCorrelation
Created: 5/3/2025
Status: ✅ Merged
Merged: 5/21/2025
Merged by: @AndrewBastin
Base:
next← Head:feat-better-verbatim-path-handling📝 Commits (1)
d383aabfix(storage): verbatim path handling in disk resolution📊 Changes
6 files changed (+114 additions, -28 deletions)
View changed files
📝
packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/Cargo.lock(+1 -0)📝
packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/Cargo.toml(+1 -0)📝
packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/storage/manager.rs(+13 -4)📝
packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/ui/windows/posit.rs(+2 -2)📝
packages/hoppscotch-desktop/src-tauri/Cargo.lock(+92 -17)📝
pnpm-lock.yaml(+5 -5)📄 Description
The storage init was failing on Windows when checking available disk space due to verbatim paths (also known as extended-length paths) returned by
std::fs::canonicalize().Windows has two path formats: traditional paths limited to 260 characters, and extended-length paths (prefixed with
\\?\) that support longer paths.While Rust's
std::pathis "platform-independent", Windows-specific behavior still requires special consideration for these extended-length paths.This fixes that.
Closes HFE-839
Closes #4859
Basically the issue occurred because
std::fs::canonicalize()on Windows may return extended-length paths when:The root issue is when comparing the canonicalized storage path against disk mount points.
A verbatim path like
\\?\C:\Users\SomeUser\AppData\...would fail to match against the disk's mount pointC:\because the comparison was done as a path string prefix check. This isn't handled bystd::path, see dunce's READMEThis caused the disk resolution to fail with "Disk not found" errors, preventing the app from initializing the bundle, which would show a
404.See the docs at (https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-file-namespaces).
duncecrate provides cross-platform path canonicalization that specifically handles Windows verbatim paths correctly. When given a verbatim path, dunce safely strips the\\?\prefix when possible while maintaining path validity:The normalization preserves the verbatim prefix only when necessary - for example with reserved filenames like
\\?\C:\COM1or paths containing certain special characters.On non-Windows systems, dunce behaves identically to
std::fs::canonicalize().Testing:
Notes to reviewers
To test this, launch the app on Windows, have the install location be ~95% full (using something like
fsutil file createnew largefile.bin <size-in-bytes>), launch the app, you should see404because the app bundle wasn't loaded due to 1. incorrect space calculation or 2. disk mismatch. Now try the same thing with this patch.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.