upload/deleted directory

What’s the purpose of the upload/deleted directory? Can it be cleared periodically?

I never heard of that directory and I don’t have it in my test installation.

Are you sure that’s not something you did manually and then forgot about?

I have it, tested right now by deleting the folder, and then bulk deleting lots of notes, and it got re-created in that process.
Seems safe to delete, probably works as or is intended as a trash can where you can recover deleted from.
(7.11.1 with no custom modules other than from the module builder)

1 Like

@helgebe thanks, we should document this.

You say it’s when you delete a note that has file attached, it gets moved from the “upload” dir into “upload/deleted”?

That is the only thing I have tested, although i tested it from the list, batch deleting, (I’m working on notes upload via api, and had lots of junk in my dev install). I’m assuming it may be for other modules as well, as long as they have some kind of attachments.
It isn’t just copied, it is cataloged there based on the generated filename. (the file 1w2e4r5t ends up in ./deleted/1w/2e/1w2e4r5t , and so on)

Are you sure that’s not an add-on doing that? Like an “undelete” add-on, I’ve seen some of those.

I searched the code but couldn’t find any reference to this directory… :huh:

SugarBean.php line 5452(sic) have a clue:
/**
* Moves file to deleted folder
*
* @return bool success of movement
*/

Interesting. There seems to be also an undelete method:

https://github.com/salesagility/SuiteCRM/blob/master/data/SugarBean.php#L5306

But it doesn’t seem to be used anywhere: https://github.com/salesagility/SuiteCRM/search?q=restoreFiles&unscoped_q=restoreFiles

Whereas the deletedFiles function is used, only in one place:

https://github.com/salesagility/SuiteCRM/search?q=deleteFiles&unscoped_q=deleteFiles

So to answer the original question, this folder stores attachments of deleted items; and you can clear it in “Admin / Repair /
Remove missed files from upload directory”.

1 Like

I also have this folder. It contains several subfolders all with a similar tree structure but all empty. It seems that the deepest folder in each is a GUID (maybe the GUID is constructed with the names of the folders above):