Skip to content

Fix: Fixed issue with stale ADS items after stream delete/move - #18755

Open
yair100 wants to merge 4 commits into
mainfrom
ya/9494-ads-watcher
Open

Fix: Fixed issue with stale ADS items after stream delete/move#18755
yair100 wants to merge 4 commits into
mainfrom
ya/9494-ads-watcher

Conversation

@yair100

@yair100 yair100 commented Jul 20, 2026

Copy link
Copy Markdown
Member

Resolved / Related Issues

To prevent extra work, all changes to the Files codebase must link to an approved issue marked as Ready to build. Please insert the issue number following the hashtag with the issue number that this Pull Request resolves.

Steps used to test these changes

Stability is a top priority for Files and all changes are required to go through testing before being merged into the repo. Please include a list of steps that you used to test this PR.

  1. Opened a folder containing a file with an ADS and confirmed it was displayed
  2. Deleted the stream and confirmed the ADS was removed from the folder
  3. Confirmed similar behavior when creating a new stream
  4. Deleted the actual file and confirmed the ADS was removed as well

@yair100
yair100 requested a review from Josh65-2201 July 20, 2026 20:51
@yair100 yair100 added the ready for review Pull requests that are ready for review label Jul 20, 2026
@Josh65-2201

Josh65-2201 commented Jul 20, 2026

Copy link
Copy Markdown
Member

Doing it In Dev, delete and create refresh correctly, rename cause the new and old name to show

Doing it out of Dev, delete doesn't refresh , create does refresh correctly, rename cause the new and old name to show

@Lamparter

Copy link
Copy Markdown
Contributor

I can reproduce that as well (renaming shows both old and new revisions before refreshing)

@yair100

yair100 commented Jul 21, 2026

Copy link
Copy Markdown
Member Author

@Lamparter even after the latest fix?

@Lamparter

Copy link
Copy Markdown
Contributor

Yes

@Josh65-2201

Josh65-2201 commented Jul 22, 2026

Copy link
Copy Markdown
Member

Renaming doesn't show the old one when doing it the first time but after it show both. Deleting ADS file outside of dev still doesn't refresh

@d2dyno1 d2dyno1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor things

if (renamed.PrimaryItemAttribute == StorageItemTypes.File)
renamed.FileExtension = Path.GetExtension(newPath);

foreach (var adsItem in filesAndFolders.ToList().OfType<AlternateStreamItem>().Where(x => x.MainStreamPath.Equals(oldPath, StringComparison.OrdinalIgnoreCase)))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
foreach (var adsItem in filesAndFolders.ToList().OfType<AlternateStreamItem>().Where(x => x.MainStreamPath.Equals(oldPath, StringComparison.OrdinalIgnoreCase)))
foreach (var adsItem in filesAndFolders.OfType<AlternateStreamItem>().Where(x => x.MainStreamPath.Equals(oldPath, StringComparison.OrdinalIgnoreCase)))

case FILE_ACTION_ADDED_STREAM:
case FILE_ACTION_REMOVED_STREAM:
case FILE_ACTION_MODIFIED_STREAM:
case FILE_ACTION_RECHECK_STREAM:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(You can add curly braces {} for cases)

Comment on lines -2948 to +2987
foreach (var adsItem in filesAndFolders.ToList().Where(x => x is AlternateStreamItem ads && ads.MainStreamPath == matchingItem.ItemPath))
foreach (var adsItem in filesAndFolders.ToList().Where(x => x is AlternateStreamItem ads && ads.MainStreamPath.Equals(matchingItem.ItemPath, StringComparison.OrdinalIgnoreCase)))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
foreach (var adsItem in filesAndFolders.ToList().Where(x => x is AlternateStreamItem ads && ads.MainStreamPath == matchingItem.ItemPath))
foreach (var adsItem in filesAndFolders.ToList().Where(x => x is AlternateStreamItem ads && ads.MainStreamPath.Equals(matchingItem.ItemPath, StringComparison.OrdinalIgnoreCase)))
foreach (var adsItem in filesAndFolders.ToArray().Where(x => x is AlternateStreamItem ads && ads.MainStreamPath.Equals(matchingItem.ItemPath, StringComparison.OrdinalIgnoreCase)))


try
{
var items = filesAndFolders.ToList();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
var items = filesAndFolders.ToList();
var items = filesAndFolders.ToArray();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Pull requests that are ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: File watcher doesn't do anything when ADS files are deleted/moved

4 participants