improved error handling on map adding
This commit is contained in:
parent
d1c3ada631
commit
269408c71a
@ -19,7 +19,7 @@ class MapActions {
|
|||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a MapActions Instance
|
* Construct a Map Actions Instance
|
||||||
*
|
*
|
||||||
* @param ManiaControl $maniaControl
|
* @param ManiaControl $maniaControl
|
||||||
*/
|
*/
|
||||||
|
@ -14,6 +14,7 @@ use ManiaControl\ManiaExchange\MXMapInfo;
|
|||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
use ManiaControl\Utils\Formatter;
|
use ManiaControl\Utils\Formatter;
|
||||||
use Maniaplanet\DedicatedServer\InvalidArgumentException;
|
use Maniaplanet\DedicatedServer\InvalidArgumentException;
|
||||||
|
use Maniaplanet\DedicatedServer\Xmlrpc\AlreadyInListException;
|
||||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||||
use Maniaplanet\DedicatedServer\Xmlrpc\FileException;
|
use Maniaplanet\DedicatedServer\Xmlrpc\FileException;
|
||||||
use Maniaplanet\DedicatedServer\Xmlrpc\IndexOutOfBoundException;
|
use Maniaplanet\DedicatedServer\Xmlrpc\IndexOutOfBoundException;
|
||||||
@ -292,14 +293,14 @@ class MapManager implements CallbackListener {
|
|||||||
|
|
||||||
$downloadFolderName = $this->maniaControl->settingManager->getSettingValue($this, 'MapDownloadDirectory', 'MX');
|
$downloadFolderName = $this->maniaControl->settingManager->getSettingValue($this, 'MapDownloadDirectory', 'MX');
|
||||||
$relativeMapFileName = $downloadFolderName . DIRECTORY_SEPARATOR . $fileName;
|
$relativeMapFileName = $downloadFolderName . DIRECTORY_SEPARATOR . $fileName;
|
||||||
$mapDir = $this->maniaControl->client->getMapsDirectory();
|
$mapDir = $this->maniaControl->server->directory->getMapsFolder();
|
||||||
$downloadDirectory = $mapDir . $downloadFolderName . DIRECTORY_SEPARATOR;
|
$downloadDirectory = $mapDir . $downloadFolderName . DIRECTORY_SEPARATOR;
|
||||||
$fullMapFileName = $downloadDirectory . $fileName;
|
$fullMapFileName = $downloadDirectory . $fileName;
|
||||||
|
|
||||||
// Check if it can get written locally
|
// Check if it can get written locally
|
||||||
if ($this->maniaControl->server->checkAccess($mapDir)) {
|
if ($this->maniaControl->server->checkAccess($mapDir)) {
|
||||||
// Create download directory if necessary
|
// 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}'.");
|
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);
|
$this->maniaControl->chat->sendError("ManiaControl doesn't have the rights to save maps.", $login);
|
||||||
return;
|
return;
|
||||||
@ -326,13 +327,18 @@ class MapManager implements CallbackListener {
|
|||||||
// Check for valid map
|
// Check for valid map
|
||||||
try {
|
try {
|
||||||
$this->maniaControl->client->checkMapForCurrentServerParams($relativeMapFileName);
|
$this->maniaControl->client->checkMapForCurrentServerParams($relativeMapFileName);
|
||||||
} catch (InvalidMapException $e) {
|
} catch (InvalidMapException $exception) {
|
||||||
$this->maniaControl->chat->sendException($e, $login);
|
$this->maniaControl->chat->sendException($exception, $login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add map to map list
|
// Add map to map list
|
||||||
|
try {
|
||||||
$this->maniaControl->client->insertMap($relativeMapFileName);
|
$this->maniaControl->client->insertMap($relativeMapFileName);
|
||||||
|
} catch (AlreadyInListException $exception) {
|
||||||
|
$this->maniaControl->chat->sendException($exception, $login);
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->updateFullMapList();
|
$this->updateFullMapList();
|
||||||
|
|
||||||
// Update Mx MapInfo
|
// Update Mx MapInfo
|
||||||
|
@ -389,7 +389,6 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
return $this->nextMap;
|
return $this->nextMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the first Queued Map
|
* Returns the first Queued Map
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user