Wwwrootbes\uploads Folder Cleanup

I am attempting to use the method referenced below to cleanup my wwwrootbes\uploads folder. It worked great in my test environment, but in production it is returning:

Error: Singular expression refers to nonexistent object.  

This error occurs after 31 seconds running. Does it fail because there is too much data? Does it time out?

Hmm. im seeing the same thing… It used to work

Thanks for the confirmation that it is failing for you also.

Do you know how to modify the session relevance to limit it to a given number of files in the uploads directory? I have played with it but haven’t found an answer.

items 1 of it whose (item 0 of it = item 0 of item 1 of it) of ((elements of ((set of unique values of (tuple string item 0 of it as lowercase) of values of results of property 1 of bes fixlets whose (name of it is "BigFix Server - Uploads Directory - Windows")) - (set of (it as lowercase) of unique values of parenthesized parts 2 of (matches (regex "(\:|%22)([0-9a-fA-F]{40})( |%22)") of it) of (scripts of actions of bes fixlets;action scripts of bes actions;scripts of actions of components of component groups of bes baselines;action scripts of member actions of bes actions;(values of shared variables of it; values of private variables of it) of bes wizards) ))), (tuple string item 0 of it, tuple string item 1 of it) of values of results of property 1 of bes fixlets whose (name of it is "BigFix Server - Uploads Directory - Windows"))

@strawgate willbe able to confirm what is wrong but I found that taking the last tuple string item 1 of it and making that tuple string item 0 of it, I got a list of sha1’s without the actual file names, so something has changed somewhere since it was initially written…

Throwing just
(tuple string item 0 of it,tuple string item 1 of it) of values of results of property 1 of bes fixlets whose (name of it is “BigFix Server - Uploads Directory - Windows”)
at the session relevance fails with the same Singular expression refers to a non existent object.

That worked! I ran the session relevance below, as you suggested, and it completed. Then I used web reports to output the results of the property “BES Server - Uploads with the File Names - Windows”. Then I put the results of the presentation debugger and web report in a spreadsheet and did a vlookup to associate the sha1 with a name. Now I have 4000 folders to delete. I wonder why over 600 of those folders are empty?

items 1 of it whose (item 0 of it = item 0 of item 1 of it) of ((elements of ((set of unique values of (tuple string item 0 of it as lowercase) of values of results of property 1 of bes fixlets whose (name of it is "BigFix Server - Uploads Directory - Windows")) - (set of (it as lowercase) of unique values of parenthesized parts 2 of (matches (regex "(\:|%22)([0-9a-fA-F]{40})( |%22)") of it) of (scripts of actions of bes fixlets;action scripts of bes actions;scripts of actions of components of component groups of bes baselines;action scripts of member actions of bes actions; (values of shared variables of it; values of private variables of it) of bes wizards)))) , (tuple string item 0 of it, tuple string item 0 of it) of values of results of property 1 of bes fixlets whose (name of it is "BigFix Server - Uploads Directory - Windows"))

If you are using the OS Deployment or the Software Distribution features, and have properly configured the BES Server Plugin Service and the Uploads Maintenance tasks associated with OSD or SWD, there is a scheduled process that deletes uploaded OSD or SWD packages when their associated content is removed through their dashboards. I expect the Uploads Maintenance may delete the files while leaving the folders behind, but that shouldn’t cause any problems. Just an explanation for one possible reason to have empty folders left behind.

Here is updated session relevance from L3 that appears to work better than the relevance above. It finds more obsolete packages, and it displays the package name. I have no idea why it displays more packages. I would like to know. It has something to do with case.

items 1 of it whose (item 0 of it = item 0 of item 1 of it) of 
 (
 (elements of ((set of unique values of (tuple string item 0 of it as lowercase) of values of results of property 1 of bes fixlets whose (name of it is "BigFix Server - Uploads Directory - Windows")) - (set of (it as lowercase) of unique values of parenthesized parts 2 of (matches (regex "(\:|%22)([0-9a-fA-F]{40})( |%22)") of it) of (scripts of actions of bes fixlets;action scripts of bes actions;scripts of actions of components of component groups of bes baselines;action scripts of member actions of bes actions;(values of shared variables of it; values of private variables of it) of bes wizards) ))),      (tuple string item 0 of it as lowercase, tuple string item 1 of it | "NoFileFound") of values of results of property 1 of bes fixlets whose (name of it is "BigFix Server - Uploads Directory - Windows"))

Don’t forget you need the analysis created by Strawgate.

@strawgate, I’m interested in trying out this process to clean up my uploads folder. I found the necessary analysis on BigFix.me, but it said i need to request access. I did that yesterday, under the same ID I use here on the forum. I hate to bug you about it, but my need is kind of time-sensitive. Would you be able to grant me access to that analysis? Thanks!

I dont use BigFix.Me anymore because nobody is maintaining the site and its barely functional.

All content is also available for direct download from github without signing up or requesting access. The analysis you’re looking for is here: https://github.com/strawgate/C3-Platform-Kickstart/blob/master/Analyses/BigFix%20Server%20-%20Uploads%20Directory%20-%20Windows.bes

1 Like

Thanks! I appreciate it!

I couldn’t find where you’re storing the session relevance for the regex used in this comparison, but I wanted to suggest a tweak to it, to match a string starting with “=” as used in the ‘add prefetch item’ syntax

add prefetch item name=CVE-2014-0160.bfz sha1=704623726be6540a4626a97a2106a7c455b2b3cb size=3823527 url=http://support.bigfix.com/labs/downloads/CVE-2014-0160.bfz

set of unique values of parenthesized parts 2 of (matches (regex "(\:|%22|=)([0-9a-fA-F]{40})( |%22)") of it) of (scripts of actions of bes fixlets;action scripts of bes actions;scripts of actions of components of component groups of bes baselines;action scripts of member actions of bes actions;(values of shared variables of it; values of private variables of it) of bes wizards)