Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.

Clean up attachments



I would like to clean up the Attachment folder on our server - I know there are a good amount I do not use or removed from a test case.

What is the best/safest way to do this? I see 2 possibilities:

  1. Compare the file names in the Attachment folder on the server (we are self hosted and currently the folder is on the C drive (I plan to work with our team to change it to a network folder) with the files in the Attachment table OR

  2. Query the Attachment table where the case_id and test_change_id are both NULL and all records returned are not used by any case…

I am going to assume that #2 is probably the best way if I understand the way the system uses the table.



Clean up orphaned attachments

Hello Brian,

Thanks for your posting! We cannot really recommend/support going through the attachments table this way because there might (and will!) be other entities with support for attachments eventually. We recommend leaving the attachments directory as is even if this means that you have a few no longer used files in this directory. TestRail also doesn’t make physical copies when copying cases with attachments and only adds a reference to the existing attachment (so attachment storage is very efficient and TestRail wouldn’t duplicate attachments file, for example).



Thanks for the info - appreciate it. :smile: