Files icon indicating copy to clipboard operation
Files copied to clipboard

Bug: Don't select items that are created externally

Open Josh65-2201 opened this issue 3 years ago • 7 comments

Description

I've mainly encountered this with Minecraft servers trying to save the world and failing because Files has select the level.dat file used when made outside of Files, the terminal will report that the file was in use. I've also had this happen with Visual Studio sometimes making a temp file instead. The preview pane isn't open.

Steps To Reproduce

  1. Download Minecraft sever (https://papermc.io/downloads/all)
  2. Start server in terminal (java -jar .jar)
  3. Open world folder
  4. Select level.dat
  5. Wait a bit
  6. See in console failed to rename, file in use error.

Requirements

  • Don't select the file if made outside of files.

Files Version

3.0.9.0

Windows Version

10.0.22621.2506

Log File

debug.log

Josh65-2201 avatar Nov 21 '23 21:11 Josh65-2201

What happens if you try deleting the same item from File Explorer?

yair100 avatar Nov 21 '23 21:11 yair100

The file delete fine in Windows File Explorer, renaming too

Josh65-2201 avatar Nov 21 '23 21:11 Josh65-2201

This can be done by moving HandleChangesOccurredAsync out of the file watcher and only calling it when using an internal action (eg rename, paste, delete etc).

yair100 avatar Jan 15 '24 18:01 yair100

related: https://github.com/files-community/Files/issues/4214#issuecomment-2010572187

rihards-simanovics avatar Mar 27 '24 19:03 rihards-simanovics

Adding #15611 for reference

yair100 avatar Jun 17 '24 13:06 yair100

I wrote an automated reproduction for this, in case it's useful for whoever picks it up.

Branch (on my own fork, not a merge request): https://github.com/mangokingTW/Files/tree/wintegrate-repro-issue-14011 CI run these numbers come from: https://github.com/mangokingTW/Files/actions/runs/33638254396 Screen recordings (run artifacts, 14-day retention): x64 · arm64

It doesn't need a Minecraft server — any second process creating a file in the open folder does it, and the test is that second process. About 20 seconds.

  step                      existing_a.txt  existing_b.txt  external_new.txt
  after_navigation          False           False           -
  after_click               True            False           -
  after_external_create     False           False           True

Still present on main (63111abb5, 4.2.26.0 sideload build) as well as 4.2.9.0.

Note the second column: as well as the new item being selected, the selection the user was holding is taken away. Only externally created items are asserted against, following the note here about HandleChangesOccurredAsync being called from the file watcher.

Two of the four tests are controls that pass (selection is readable and not simply True; the watcher did see the file), so a red result isn't just a broken harness.

Not a proposal to add a second test framework — this lives in tests/ui-repro/ and nothing in the solution picks it up. The measurement is the useful part; porting it to the existing Appium tests would be a small job.

Driven with wintegrate, a library I'm building to make Windows GUI testing actually work on hosted CI runners. Files is one of four real applications it drives as its own release gate, and it is the reason the library can focus a WinUI 3 content island at all — a DesktopChildSiteBridge will happily be foreground while every keystroke goes nowhere.

It has only been run on Windows 11 / Server 2025. It closes any running Files.exe and sets a few startup settings in LocalState/settings/user_settings.json so the launch is deterministic, putting the original file back afterwards.

mangokingTW avatar Sep 01 '26 06:09 mangokingTW

I plan to investigate this. I will use the reproduction from the thread to check whether Files still selects items created by another process.

ASVLCII avatar Nov 29 '26 11:11 ASVLCII