Thanks Johnny for your fast answer, and I am very proud to help improve GC.
I have been doing some tests with the fuction setFieldUpload() and I think I found some issues as well. I will try to explain by points:
1.- lf you upload one file with the same name than an existing one (it can be the same file or not); GC upload and register it with a modified name adding some random alpha-numeric code at the end of the name. I understand that this behaviour is “coherent” however I would like to have any type of “alarm-message” to inform me about that.
2.- In my case… I need to have different registers in the database that point to the same file (an image in my case), so Point 1 behaviour can be a problem. However, I have found a solution, if it is used the “Clone” function from an existing register it is possible to have two (or more) registers point to the same file. Maybe my case is not really common, and to have the posibility of doing it thru “Clone” function can be supposed as a bug.
3.- Once I get some registers pointing to the same file (using “Clone”); if I set the configuration with “‘remove_file_on_delete’ => true,” if one of this registers is deleted the file is deleted without checking that there are others registers that point to the same file. You can cosider this a bug or you can cosider “Point 2 - Clone register” behaviour a bug…
So… I was thinking about it, and I propose the following solution (however it can be others or it can be left as it is now as well…):
1.- To implement a checking in the deletion of the files: Before deleting the file, it is needed to check if there is other register that point this file. The deletion is done only if there is no other register pointing the same file.
2.- To implement a “multi_file_register” parameter in configuration (or in setFieldUpload() funtion) in order to control the behaviour for “already existing files”. The possible behaviour can be:
If “multi_file_register” is set to TRUE:
When a file with the same name than existing one is upload: The register is done however the file is not upload. A message informing of this behaviour would be apreciated, maybe a “perfect behaviour” would be a checking-comparison between the two files and to see if they are really the same file or different files with the same name (I don’t know if this can be complicated)
When it is clone a register with the same file name: the register is done without no problem.
When it is deleted a register with “‘remove_file_on_delete’ => true,”: The file is deleted only if there is no other register pointing the file.
If “multi_file_register” is set to FALSE:
When a file with the same name than existing one is upload: The file is upload but with a updated name (as it is happening now). A message informing of this behaviour would be apreciated.
When it is clone a register with the same file name: An error message will appear informing that a file with this file already exists.
When it is deleted a register with “‘remove_file_on_delete’ => true,”: The file is deleted directly (we now that it is the only register).
Ok… so that’s all… I hope this post help to improve, however I know that can be other possible solutions, I try to do it in the way that different desired behaviours can be attendended. Of course other possible it is that everyone adapt the program with different callbacks funtions.