remove map from the playlist when erasing map file

This commit is contained in:
Beu
2025-06-22 11:47:22 +02:00
parent a769fec577
commit a42c12ace8

View File

@ -557,6 +557,17 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$fileName = base64_decode(substr($actionName, strlen(self::ACTION_ERASE_FILE))); $fileName = base64_decode(substr($actionName, strlen(self::ACTION_ERASE_FILE)));
$folderPath = $player->getCache($this, self::CACHE_FOLDER_PATH); $folderPath = $player->getCache($this, self::CACHE_FOLDER_PATH);
$filePath = $folderPath . $fileName; $filePath = $folderPath . $fileName;
$maps = $this->maniaControl->getMapManager()->getMaps();
$mapsFolder = $this->maniaControl->getServer()->getDirectory()->getMapsFolder();
$filteredMaps = array_filter($maps, function ($item) use ($mapsFolder, $filePath) {
return ($mapsFolder . $item->fileName === $filePath);
});
foreach ($filteredMaps as $map) {
Logger::log('Map "'. $filePath .'" loaded by the server, removing it from the playlist before erasing the file');
$this->maniaControl->getMapManager()->removeMap($player, $map->uid);
}
if (@unlink($filePath)) { if (@unlink($filePath)) {
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
'Erased %s!', 'Erased %s!',