New uploaded files will be entered into to uploaded_unusedfiles table. Thereby new files will be delted after 2 hours. This isn't a desired behavior.
The function trackUploadedFiles was the reason for the entry of the files in the table. Only a re-saving of the item has the files deted from the table.
To change this behaviorm the trackUploadedFiles must be called at a different place in the code. Exatcly inside of the if-instruction. When add the item it must be called after saving. When edit the item ist must be called befor saving.