Skip to content

Commit

Permalink
Merge pull request #384 from jonasdekeukelaere/521-user-template-images
Browse files Browse the repository at this point in the history
Fix delete user template directory
  • Loading branch information
jonasdekeukelaere authored Oct 11, 2024
2 parents 3405a9f + a4c1cc0 commit a2c2a0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/Backend/Modules/Pages/Ajax/RemoveUploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public function execute(): void

$path = FRONTEND_FILES_PATH . '/Pages/' . $directory . '/' . $file;

if (!is_file($path)) {
$this->output(Response::HTTP_OK);

return;
}

$filesystem = new Filesystem();
if ($filesystem->exists($path)) {
$filesystem->remove($path);
Expand Down
4 changes: 2 additions & 2 deletions src/Backend/Modules/Pages/Js/Pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ jsBackend.pages.extras = {
)

// send a request to remove the old image if the old image doesn't have the same name
if (oldImage !== response.data) {
if (oldImage && oldImage !== response.data) {
$.ajax({
data: {
fork: {module: 'Pages', action: 'RemoveUploadedFile'},
Expand Down Expand Up @@ -1022,7 +1022,7 @@ jsBackend.pages.extras = {
)

// send a request to remove the old image if the old image doesn't have the same name
if (oldImage !== response.data) {
if (oldImage && oldImage !== response.data) {
$.ajax({
data: {
fork: {module: 'Pages', action: 'RemoveUploadedFile'},
Expand Down

0 comments on commit a2c2a0a

Please sign in to comment.