Fixed [ERROR] Current hashes file cannot be determined. [XFMG&XFRM]

Dhekhanur

Member
Affected version
2.3.0 RC 5
Manual file clean-up of mg and rm addons results in

[ERROR] Current hashes file cannot be determined.

Steps to reproduce:

Install new 2.3.0 RC4 upgrade to RC5 and post-upgrade
Run in CLI

Bash:
php cmd.php xf:file-clean-up XFMG
Bash:
php cmd.php xf:file-clean-up XFRM
 
Last edited:
Yes I think this could be a legitimate bug actually.

The good news is, if the command is giving you this error then the file clean up has already been run automatically.

The bad news is that the hashes.json file gets deleted because the hashes.json file is not listed in the hashes.json file 🙃

No big issue, it will sort itself out in the next release and we'll make sure that file isn't deleted going forwards.
 
Yes I think this could be a legitimate bug actually.

The good news is, if the command is giving you this error then the file clean up has already been run automatically.

The bad news is that the hashes.json file gets deleted because the hashes.json file is not listed in the hashes.json file 🙃

No big issue, it will sort itself out in the next release and we'll make sure that file isn't deleted going forwards.
My first thought when I saw the new feature was exactly this. If it's relying on hashes.json to decide what to delete, that's a little scary. Oops, hashes.json or robots.txt or the empty html files some directories have. Or how about config.php? 😂

I have an addon that does a cleanup of old files, but it was wanting to delete a lot of things that I didn't really want to delete because they were missing from hashes.json, so I ended up just using it as something to tell me the files and I could make the decision myself.

After it was said an done and I removed the files that should have been removed, there was still ~20 files that it wanted to delete because they were missing from hashes.json:


There's even been times where PHP files have been missing from the hashes.json file:


Haven't looked at it yet, but hopefully the cleanup tool has a dry run option so we can see what it will delete.
 
I think a dry-run option would be great. We use a whitelist approach for directories, so it doesn't actually touch anything outside of specific src/ sub-directories regardless of the hash contents. Not to say nothing could ever go wrong (as demonstrated here), but it does help mitigate some of the concerns. Files generated at runtime should never be stored in the src/ directory, and certainly never in src/XF/.
 
Just to add to this that while you're unlikely to keep the importers of the forums (XFI) around long-term they also lack the hashes.json files hash included in the hashes.json (did a quick cat grep)
this works as expected:
Bash:
php cmd.php xf:file-clean-up XFI

(edit: TL;DR of this thread only the XF "addon" doesn't delete it's hashes.json due to hashes.json hash missing in the file. (XF hashes.json also lacks the hash for the files but somewhere there is a check that it doesn't get deleted unlike for the other addons))

Another thing that is kind of related to this {{ ASSUMPTION }} is that the file health checker does not check for the existence of the hashes.json so while they are missing you are not made aware of the fact that they are in fact deleted. (PS: checked again and that's because the file checker utility does not check even first-party addon files (if the hashes.json file is missing))
 
Last edited:
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.3.0).

Change log:
Do not allow deletion of certain files, including the hashes.json file.
There may be a delay before changes are rolled out to the XenForo Community.
 
My first thought when I saw the new feature was exactly this. If it's relying on hashes.json to decide what to delete, that's a little scary. Oops, hashes.json or robots.txt or the empty html files some directories have. Or how about config.php? 😂

I have an addon that does a cleanup of old files, but it was wanting to delete a lot of things that I didn't really want to delete because they were missing from hashes.json, so I ended up just using it as something to tell me the files and I could make the decision myself.

After it was said an done and I removed the files that should have been removed, there was still ~20 files that it wanted to delete because they were missing from hashes.json:


There's even been times where PHP files have been missing from the hashes.json file:


Haven't looked at it yet, but hopefully the cleanup tool has a dry run option so we can see what it will delete.
We have a --dry-run option now too:

Code:
~/Herd/23x git:[main]
php cmd.php xf:file-clean-up XF --dry-run

                                                                                                                        
 [INFO] Found 2 files to be deleted:                                                                                   
                                                                                                                        

 * src/XF/AdminSearch/AdminTemplateHandlerHandler.php
 * src/XF/AdminSearch/EmailTemplateHandlerHandler.php

                                                                                                                        
 [WARNING] --dry-run was used, no files will be deleted.
 
Back
Top Bottom