Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary rescan after copying file #102260

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Jan 31, 2025

Fixes #101290

The bug is caused by ProgressDialog manual iteration that makes scan run during importing. Not sure if it's a correct fix though.

@Hilderin
Copy link
Contributor

Hilderin commented Feb 1, 2025

I'm concerned a bit with this solution because it does not really prevent 2 scans to be executed at the same time. 2 scans at the same time could lead to a corruption of EditorFileSystem::filesystem.

I think the real issue is that a scan is started in FileSystemDock::_move_operation_confirm when is_copied is true at line 1972 while _try_duplicate_item and EditorFileSystem::copy_file queued a refresh_filesystem in EditorFileSystem.
Then, we have 2 scans running at the same time.

First, I think the rescan in FileSystemDock::_move_operation_confirm is useless following #97090. I tested, and just that fixes the issue.

Second, I think to avoid this problem elsewhere in the future, a much global way to fix that should be to prevent 2 scans at the same time. I suggest:

  • Adding a check on refresh_queued In EditorFileSystem::scan() and EditorFileSystem::scan_changes to skip the scan if a refresh is queued.
  • Adding a check on if (scanning || scanning_changes || thread.is_started()) { in EditorFileSystem::_refresh_filesystem
  • Adding a check on refresh_queued In EditorFileSystem::_notification() in case NOTIFICATION_PROCESS, exactly like the prevent_recursive_process_hack.

I created a proof of concept PR the test my hypothesis: master...Hilderin:godot:fix-double-scan-file-system

@KoBeWi KoBeWi force-pushed the ProgressDialog_my_nemesis branch from c855393 to 91658ac Compare February 1, 2025 16:19
@KoBeWi KoBeWi requested a review from a team as a code owner February 1, 2025 16:19
@KoBeWi
Copy link
Member Author

KoBeWi commented Feb 1, 2025

Changed to a different fix as suggested.

@KoBeWi KoBeWi force-pushed the ProgressDialog_my_nemesis branch from 91658ac to 9a08691 Compare February 1, 2025 16:20
@KoBeWi KoBeWi changed the title Don't scan filesystem while importing Remove unnecessary rescan after copying file Feb 1, 2025
Copy link
Contributor

@Hilderin Hilderin left a comment

Choose a reason for hiding this comment

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

Tested locally and that fixes the issue. Not sure the extra suggested checks are necessary for now, so that's ok.

@KoBeWi KoBeWi force-pushed the ProgressDialog_my_nemesis branch from 9a08691 to 46d8231 Compare February 1, 2025 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash when duplicating file with Ctrl+Drag and drop
2 participants