Skip to content

Commit

Permalink
Update MediaSourceService.php
Browse files Browse the repository at this point in the history
  • Loading branch information
DonRichards authored Feb 16, 2023
1 parent 2794f01 commit 5585f89
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/MediaSource/MediaSourceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,18 @@ public function putToNode(
}

$directory = $this->fileSystem->dirname($content_location);

// Check if the directory is writable.
if (!is_writable(dirname($directory))) {
$parent_directory = dirname($directory);
$error_current_user = shell_exec('whoami');
$sanitized_current_user = str_replace(array("\n", "\r"), '', $error_current_user);
throw new HttpException(500, "The user '$sanitized_current_user' does not have permissions to write to: '$parent_directory' . Error");
}


if (!$this->fileSystem->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) {
throw new HttpException(500, "The destination directory does not exist, could not be created, or is not writable");
throw new HttpException(500, "The destination directory does not exist, could not be created, or is not writable: $directory");
}

// Copy over the file content.
Expand Down

0 comments on commit 5585f89

Please sign in to comment.