Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Command/GetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

try {
if ($this->storage->checkIfProjectExists($project) === false) {
$output->writeln(sprintf("<error>Requested project does not exist: %s </error>", $project));
return static::RETURN_CODE_DOWNLOAD_ERROR;
}

if (!$file) {
$file = $this->storage->getLatestFile($project);
if (!$file) {
$output->writeln(sprintf("<error>Requested file does not exist: %s </error>", $file));
return static::RETURN_CODE_DOWNLOAD_ERROR;
}
}

$output->writeln(
Expand Down
28 changes: 28 additions & 0 deletions src/Service/Storage/S3.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,32 @@ public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
}

/**
* @inheritDoc
*/
public function checkIfFileExists($file, $project)
{
$bucket = $this->getBucket();
$key = $this->getFileKey($project, $file);

try {
return $this->getClient()->doesObjectExist($bucket, $key);
} catch (\Exception $e) {
throw new ServiceException($e->getMessage());
}
}

/**
* @inheritDoc
*/
public function checkIfProjectExists($project)
{
$bucket = $this->getBucket();
try {
return $this->getClient()->doesObjectExist($bucket, $project);
} catch (\Exception $e) {
throw new ServiceException($e->getMessage());
}
}
}
18 changes: 18 additions & 0 deletions src/Service/StorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,22 @@ public function delete($project, $file);
* @return void
*/
public function clean($project, $keep = 5);

/**
* Check if the given file exists for the project to allow us to gracefully handle files that don't
*
* @param string $file The file to check the project for
* @param string $project The project to check
*
* @return bool
*/
public function checkIfFileExists($file, $project);

/**
* Check if the given project exists to allow us to gracefully handle projects that don't
*
* @param $project
* @return bool
*/
public function checkIfProjectExists($project);
}