Browse code

Try to not overwrite existing files

Benjamin Roth authored on12/10/2023 15:08:44
Showing1 changed files
... ...
@@ -214,6 +214,14 @@ class SecureDownloadsJob
214 214
                     $strStartPath .= $folder . '/';
215 215
                 }
216 216
 
217
+                // Do not overwrite existing files
218
+                $copyId = 1;
219
+                $baseFilename = $sanitizedFilename;
220
+                while(file_exists(TL_ROOT . "/".$strTargetFolder.'/'.$sanitizedFilename))
221
+                {
222
+                    $sanitizedFilename = $baseFilename.'_'.$copyId++;
223
+                }
224
+
217 225
                 // Try to copy file
218 226
                 if (!Files::getInstance()->copy($objFile->path,$strTargetFolder.'/'.$sanitizedFilename))
219 227
                 {