From 3452cb01d051d6214e0bcf7e9872640170ada6d4 Mon Sep 17 00:00:00 2001 From: RickyRister <42636155+RickyRister@users.noreply.github.com> Date: Fri, 27 Dec 2024 22:15:25 -0800 Subject: [PATCH] fix replay download not working if replay folder is empty (#5355) * fix downloading single replays * fix downloading replay folder --- cockatrice/src/client/tabs/tab_replays.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cockatrice/src/client/tabs/tab_replays.cpp b/cockatrice/src/client/tabs/tab_replays.cpp index 052c5aa31..8382c1c39 100644 --- a/cockatrice/src/client/tabs/tab_replays.cpp +++ b/cockatrice/src/client/tabs/tab_replays.cpp @@ -326,7 +326,8 @@ void TabReplays::downloadNodeAtIndex(const QModelIndex &curLeft, const QModelInd const QString name = QString::number(replayMatch->game_id()) + "_" + QString::fromStdString(replayMatch->game_name()); - const auto newDirIndex = localDirModel->mkdir(curLeft, name); + const auto dirIndex = curLeft.isValid() ? curLeft : localDirModel->index(localDirModel->rootPath()); + const auto newDirIndex = localDirModel->mkdir(dirIndex, name); int rows = serverDirView->model()->rowCount(curRight); for (int i = 0; i < rows; i++) { @@ -335,7 +336,8 @@ void TabReplays::downloadNodeAtIndex(const QModelIndex &curLeft, const QModelInd } } else if (const auto replay = serverDirView->getReplay(curRight)) { // node at index is a replay - const QString filePath = localDirModel->filePath(curLeft) + QString("/replay_%1.cor").arg(replay->replay_id()); + const QString dirPath = curLeft.isValid() ? localDirModel->filePath(curLeft) : localDirModel->rootPath(); + const QString filePath = dirPath + QString("/replay_%1.cor").arg(replay->replay_id()); Command_ReplayDownload cmd; cmd.set_replay_id(replay->replay_id());