improved error handling on map adding

This commit is contained in:
Steffen Schröder 2014-06-23 16:04:00 +02:00
parent d1c3ada631
commit 269408c71a
3 changed files with 13 additions and 8 deletions

View File

@ -19,7 +19,7 @@ class MapActions {
private $maniaControl = null;
/**
* Create a MapActions Instance
* Construct a Map Actions Instance
*
* @param ManiaControl $maniaControl
*/
@ -43,4 +43,4 @@ class MapActions {
} catch (ChangeInProgressException $e) {
}
}
}
}

View File

@ -14,6 +14,7 @@ use ManiaControl\ManiaExchange\MXMapInfo;
use ManiaControl\Players\Player;
use ManiaControl\Utils\Formatter;
use Maniaplanet\DedicatedServer\InvalidArgumentException;
use Maniaplanet\DedicatedServer\Xmlrpc\AlreadyInListException;
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
use Maniaplanet\DedicatedServer\Xmlrpc\FileException;
use Maniaplanet\DedicatedServer\Xmlrpc\IndexOutOfBoundException;
@ -292,14 +293,14 @@ class MapManager implements CallbackListener {
$downloadFolderName = $this->maniaControl->settingManager->getSettingValue($this, 'MapDownloadDirectory', 'MX');
$relativeMapFileName = $downloadFolderName . DIRECTORY_SEPARATOR . $fileName;
$mapDir = $this->maniaControl->client->getMapsDirectory();
$mapDir = $this->maniaControl->server->directory->getMapsFolder();
$downloadDirectory = $mapDir . $downloadFolderName . DIRECTORY_SEPARATOR;
$fullMapFileName = $downloadDirectory . $fileName;
// Check if it can get written locally
if ($this->maniaControl->server->checkAccess($mapDir)) {
// Create download directory if necessary
if (!is_dir($downloadDirectory) && !mkdir($downloadDirectory)) {
if (!is_dir($downloadDirectory) && !mkdir($downloadDirectory) || !is_writable($downloadDirectory)) {
trigger_error("ManiaControl doesn't have to rights to save maps in '{$downloadDirectory}'.");
$this->maniaControl->chat->sendError("ManiaControl doesn't have the rights to save maps.", $login);
return;
@ -326,13 +327,18 @@ class MapManager implements CallbackListener {
// Check for valid map
try {
$this->maniaControl->client->checkMapForCurrentServerParams($relativeMapFileName);
} catch (InvalidMapException $e) {
$this->maniaControl->chat->sendException($e, $login);
} catch (InvalidMapException $exception) {
$this->maniaControl->chat->sendException($exception, $login);
return;
}
// Add map to map list
$this->maniaControl->client->insertMap($relativeMapFileName);
try {
$this->maniaControl->client->insertMap($relativeMapFileName);
} catch (AlreadyInListException $exception) {
$this->maniaControl->chat->sendException($exception, $login);
return;
}
$this->updateFullMapList();
// Update Mx MapInfo

View File

@ -389,7 +389,6 @@ class MapQueue implements CallbackListener, CommandListener {
return $this->nextMap;
}
/**
* Returns the first Queued Map
*