fix target creation for public links

fix #11645

PR against stable7 because master is in transition to a different implementation.

cc @PVince81 
No it is a additional fix how the path to the file is constructed. Without the patch you will not be able to download a public link share of a single file if it was re-shared before.