From 291d2fcb9b483fda200a5d22b1c9adc07c7d401d Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 26 Aug 2022 18:57:44 -0500 Subject: [PATCH] fix: when renaming local data files fails, set the torrent error and pause the torrent (#3717) --- libtransmission/inout.cc | 1 + libtransmission/peer-io.cc | 1 + libtransmission/torrent.cc | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libtransmission/inout.cc b/libtransmission/inout.cc index a51916c6f..7177d9977 100644 --- a/libtransmission/inout.cc +++ b/libtransmission/inout.cc @@ -218,6 +218,7 @@ int readOrWritePiece(tr_torrent* tor, IoMode io_mode, tr_block_info::Location lo { auto const path = tr_pathbuf{ tor->downloadDir(), '/', tor->fileSubpath(file_index) }; tor->setLocalError(fmt::format(FMT_STRING("{:s} ({:s})"), tr_strerror(err), path)); + tr_torrentStop(tor); } ++file_index; diff --git a/libtransmission/peer-io.cc b/libtransmission/peer-io.cc index 9da5bf10d..131730643 100644 --- a/libtransmission/peer-io.cc +++ b/libtransmission/peer-io.cc @@ -827,6 +827,7 @@ void tr_peerIoClear(tr_peerIo* io) tr_peerIoSetIOFuncs(io, nullptr, nullptr, nullptr, nullptr); tr_peerIoSetEnabled(io, TR_UP, false); tr_peerIoSetEnabled(io, TR_DOWN, false); + io_close_socket(io); } int tr_peerIoReconnect(tr_peerIo* io) diff --git a/libtransmission/torrent.cc b/libtransmission/torrent.cc index 1712b5d06..81af26cdd 100644 --- a/libtransmission/torrent.cc +++ b/libtransmission/torrent.cc @@ -2132,12 +2132,13 @@ static void setLocationInEventThread( ok = tor->metainfo_.files().move(tor->currentDir(), path, setme_progress, tor->name(), &error); if (error != nullptr) { - tr_logAddError(fmt::format( + tor->setLocalError(fmt::format( _("Couldn't move '{old_path}' to '{path}': {error} ({error_code})"), fmt::arg("old_path", tor->currentDir()), fmt::arg("path", path), fmt::arg("error", error->message), fmt::arg("error_code", error->code))); + tr_torrentStop(tor); tr_error_clear(&error); } }