dsccommunity / xPSDesiredStateConfiguration

DSC resources for configuring common operating systems features, files and settings.
https://dsccommunity.org
MIT License
211 stars 135 forks source link

When a file exists, and matches checksum, the cache still considers it invalid #723

Open XVII opened 3 years ago

XVII commented 3 years ago

The Test-TargetResource returns $false even though the file may match the checksum. This is because when deploying a new configuration, it clears the "attribute cache" that's used to tell whether it matches the source or not (as documented).

In my eyes, it's more important that the contents match over the attributes matching the cache. -MatchSource should work with the CheckSum rather than just the cached file attributes alone.

I propose the $fileExists -eq True is removed as it should check the file checksum, no matter if it's in the attribute cache or otherwise. I guess this would mean an extra hash calculation, but if -MatchSource is set, the file hashes should match too.

For Files:

https://github.com/dsccommunity/xPSDesiredStateConfiguration/blob/475885cb016e987a43c5433b0e8a03f7decbc5a1/source/DSCResources/DSC_xRemoteFile/DSC_xRemoteFile.psm1#L523-L526

and for Directories:

https://github.com/dsccommunity/xPSDesiredStateConfiguration/blob/475885cb016e987a43c5433b0e8a03f7decbc5a1/source/DSCResources/DSC_xRemoteFile/DSC_xRemoteFile.psm1#L575-L578

We use this for a file that gets copied onto a server which becomes locked. We've noticed that DSC xRemoteFile is trying to update this file, even though it shouldn't be touching it -- the hash matches.

brwilkinson commented 1 year ago

was this abandoned, since I shows assigned?

johlju commented 1 year ago

It seems there were no one in the community to reviewed the PR so it could be merge, and the contributor eventually removed the working branch so the PR closed. If someone send in a new PR then someone in the community have a chance to reviewed and we can merge it. 🙂