Skip to content

Fixed: Directory scanner skipping OneDrive cloud folders#883

Merged
Sewer56 merged 2 commits into
masterfrom
improve-onedrive-detection-and-fix-file-exist-checks
Jun 14, 2026
Merged

Fixed: Directory scanner skipping OneDrive cloud folders#883
Sewer56 merged 2 commits into
masterfrom
improve-onedrive-detection-and-fix-file-exist-checks

Conversation

@Sewer56

@Sewer56 Sewer56 commented Jun 13, 2026

Copy link
Copy Markdown
Member

Summary

Two bugs fixed around cloud sync folders:

  1. Directory enumeration skipped cloud folders. WindowsDirectorySearcher dropped any entry with the ReparsePoint attribute unless it also had Offline. Some cloud folders (unfortunately) carry a different reparse tag without Offline. This caused mods/configs inside them to go undetected.

  2. Cloud detection used substring matching. path.Contains("OneDrive") was a poor hack that only covered OneDrive and broke on non-default roots or any folder literally named OneDrive. We now detect any cloud sync provider via OneDrive env vars + the Windows Cloud Files API (CfGetSyncRootInfoByPath) + known folder names as fallback.

- WindowsDirectorySearcher now only skips name-surrogate reparse points
  (symlinks/junctions). OneDrive cloud folders use a different reparse
  tag and are no longer incorrectly skipped during directory enumeration,
  which caused mod/user configs inside them to go undetected.
- Detect OneDrive paths via environment variables instead of substring
  matching, fixing false positives/negatives in installer and launcher.
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a389fd3b-1eb4-48aa-bb4d-f2e23009454d

📥 Commits

Reviewing files that changed from the base of the PR and between 09b92a5 and ba760d1.

📒 Files selected for processing (5)
  • source/Reloaded.Mod.Installer.Lib/Settings.cs
  • source/Reloaded.Mod.Launcher.Lib/Commands/Application/AddApplicationCommand.cs
  • source/Reloaded.Mod.Launcher.Lib/Utility/PathUtility.cs
  • source/Reloaded.Mod.Launcher/App.xaml.cs
  • source/Reloaded.Mod.Loader.IO/Utility/Windows/WindowsDirectorySearcher.cs
✅ Files skipped from review due to trivial changes (1)
  • source/Reloaded.Mod.Launcher/App.xaml.cs
🚧 Files skipped from review as they are similar to previous changes (4)
  • source/Reloaded.Mod.Launcher.Lib/Commands/Application/AddApplicationCommand.cs
  • source/Reloaded.Mod.Installer.Lib/Settings.cs
  • source/Reloaded.Mod.Loader.IO/Utility/Windows/WindowsDirectorySearcher.cs
  • source/Reloaded.Mod.Launcher.Lib/Utility/PathUtility.cs

📝 Walkthrough

Walkthrough

This PR adds cloud-sync path detection, uses it in installer and launcher path checks, and refines directory enumeration to skip only name-surrogate reparse-point directories.

Changes

Cloud-Sync Path Detection System

Layer / File(s) Summary
Cloud-sync detection utility
source/Reloaded.Mod.Launcher.Lib/Utility/PathUtility.cs
PathUtility.IsPathInCloudSyncFolder adds tiered cloud-sync detection using OneDrive environment variables, CfGetSyncRootInfoByPath, and known cloud folder names, with IsUnder containment checks and native interop declarations.
Installer safe path check
source/Reloaded.Mod.Installer.Lib/Settings.cs
GetSafeInstallPath() now uses cloud-sync detection instead of the earlier OneDrive and non-ASCII heuristic.
Launcher path warnings
source/Reloaded.Mod.Launcher.Lib/Commands/Application/AddApplicationCommand.cs, source/Reloaded.Mod.Launcher/App.xaml.cs
Application selection and startup path warnings now use PathUtility.IsPathInCloudSyncFolder alongside the existing non-ASCII checks, replacing OneDrive-only substring matching.

Reparse Point Filtering Refinement

Layer / File(s) Summary
Name-surrogate reparse filtering
source/Reloaded.Mod.Loader.IO/Utility/Windows/WindowsDirectorySearcher.cs
Directory enumeration now skips reparse-point directories only when IsNameSurrogateReparsePoint confirms a name-surrogate tag, and the helper plus WinAPI declarations were added for reparse-point inspection.

🎯 4 (Complex) | ⏱️ ~45 minutes

🐰 I hop through clouds and paths with care,
New checks now guard the installer’s lair.
Reparse twigs and junctions bloom,
Yet only the right ones leave the room.
With soft little ears and steady feet,
I cheer for code that’s neat and complete.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fixed: Directory scanner skipping OneDrive cloud folders' directly addresses the main bug fix described in the PR objectives—the directory scanner was incorrectly skipping cloud folders due to improper reparse-point handling.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch improve-onedrive-detection-and-fix-file-exist-checks

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@source/Reloaded.Mod.Installer.Lib/Settings.cs`:
- Around line 61-74: The installer’s IsPathInCloudSyncFolder currently only
checks IsInOneDrive and IsInRegisteredCloudSyncRoot, causing mismatch with the
launcher's third-tier known-folder fallback; update IsPathInCloudSyncFolder to
include the same third-tier check used by the launcher (for example by calling
the launcher's known-folder fallback method, e.g.
IsInKnownFolderCloudFilesFallback(path) or the shared utility that launcher
uses) so the return becomes IsInOneDrive(fullPath) ||
IsInRegisteredCloudSyncRoot(fullPath) ||
IsInKnownFolderCloudFilesFallback(fullPath); ensure you reference and reuse the
existing launcher/shared fallback implementation rather than duplicating logic.

In `@source/Reloaded.Mod.Loader.IO/Utility/Windows/WindowsDirectorySearcher.cs`:
- Around line 243-244: The IsNameSurrogateReparsePoint helper currently uses the
wrong bitmask: change the REPARSE_TAG_NAME_SURROGATE constant in
WindowsDirectorySearcher.cs from 0x80000000 to 0x20000000 (the Microsoft
"name-surrogate" / bit 29 mask) and keep the existing check (*(uint*)buffer &
REPARSE_TAG_NAME_SURROGATE) != 0 so name-surrogate reparse points are detected
correctly and cloud reparse tags are not misclassified.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d59e8d5c-f159-48c3-a285-769297153162

📥 Commits

Reviewing files that changed from the base of the PR and between 4fd2012 and 09b92a5.

📒 Files selected for processing (5)
  • source/Reloaded.Mod.Installer.Lib/Settings.cs
  • source/Reloaded.Mod.Launcher.Lib/Commands/Application/AddApplicationCommand.cs
  • source/Reloaded.Mod.Launcher.Lib/Utility/PathUtility.cs
  • source/Reloaded.Mod.Launcher/App.xaml.cs
  • source/Reloaded.Mod.Loader.IO/Utility/Windows/WindowsDirectorySearcher.cs

Comment thread source/Reloaded.Mod.Installer.Lib/Settings.cs
Comment thread source/Reloaded.Mod.Loader.IO/Utility/Windows/WindowsDirectorySearcher.cs Outdated
- Replace OneDrive-only substring/env-var checks with layered detection
  (OneDrive env vars, Cloud Files API via CfGetSyncRootInfoByPath,
  known cloud folder names) so Dropbox, Google Drive, iCloud, etc. are caught.
- cldapi missing on older than Windows 10 1709 falls back gracefully.
- Installer keeps two tiers (Desktop is only redirected by OneDrive).
@Sewer56 Sewer56 force-pushed the improve-onedrive-detection-and-fix-file-exist-checks branch from 09b92a5 to ba760d1 Compare June 13, 2026 22:24
@Sewer56

Sewer56 commented Jun 13, 2026

Copy link
Copy Markdown
Member Author

@Opst34

Would you be able to test this?

2 things to test; take a backup of your Reloaded folder first just in case:

Installer

https://github.com/Reloaded-Project/Reloaded-II/actions/runs/27480906195/artifacts/7615083550
Does it avoid installing in OneDrive?

Launcher

Is the fix logic still working? If you use this built version (just extract anywhere), does stuff work?
https://github.com/Reloaded-Project/Reloaded-II/actions/runs/27480906195/artifacts/7615083396

I don't have a Windows virtual machine ready; so it may be easier to just ask.

@Opst34

Opst34 commented Jun 14, 2026

Copy link
Copy Markdown

I must clarify, though, that the 'installation' in OneDrive was a manual sync (error) on my part, not an automatic sync.

Unless https://github.com/Reloaded-Project/Reloaded-II/actions/runs/27480906195/artifacts/7615083550 also prevents manual syncing.

@Opst34

Opst34 commented Jun 14, 2026

Copy link
Copy Markdown

Update for https://github.com/Reloaded-Project/Reloaded-II/actions/runs/27480906195/artifacts/7615083550:

I'm still unsure about what you meant by 'installation' in OneDrive. However, both the installer file and the newly created Reloaded-II folder were immediately synced after I prompted them.

As an added note, the fundamental mods weren't automatically downloaded when I used this installer.

image image

@Opst34

Opst34 commented Jun 14, 2026

Copy link
Copy Markdown

Update for https://github.com/Reloaded-Project/Reloaded-II/actions/runs/27480906195/artifacts/7615083396:

The original fix logic still works.

I extracted the zip into a backup I had of Reloaded-II (not from the new installer). I don't know if the new launcher was supposed to change anything... but, yes. New stuff still works.

@Sewer56

Sewer56 commented Jun 14, 2026

Copy link
Copy Markdown
Member Author

@Opst34 Thanks 👏

When you run the installer, it does a check, and tries to prevent itself from installing into Cloud Storage; i.e. OneDrive.

I was curious if it avoided Desktop when you ran Setup.exe, and instead installed into C:\Reloaded-II

@Opst34

Opst34 commented Jun 14, 2026

Copy link
Copy Markdown

Noted. Good luck coding the files to completely avoid OneDrive, if it's even possible.

Though, to be honest, one can avoid this issue by simply not being a dumbass like me who accidentally started sync. They wouldn't be in OneDrive otherwise.

@Sewer56 Sewer56 merged commit 99bf76d into master Jun 14, 2026
4 checks passed
@Sewer56 Sewer56 deleted the improve-onedrive-detection-and-fix-file-exist-checks branch June 14, 2026 19:49
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.

2 participants