fixup: fix fd regression in tr_open_files (#3036)

Fixes #3032.
This commit is contained in:
Charles Kerr 2022-04-30 23:30:49 -05:00 committed by GitHub
parent 4cc952f0ca
commit 88a0b292d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View File

@ -9,9 +9,9 @@
#error only libtransmission should #include this header.
#endif
#include <cstdint> // uint64_t
#include <cstdint>
#include <optional>
#include <utility> // std::pair
#include <utility>
#include "transmission.h"
@ -48,11 +48,17 @@ private:
struct Val
{
Val& operator=(Val const&) = delete;
Val& operator=(Val&&) = default;
Val() = default;
Val() noexcept = default;
Val(Val const&) = delete;
Val(Val&&) = default;
Val& operator=(Val const&) = delete;
Val(Val&& that) noexcept {
*this = std::move(that);
}
Val& operator=(Val&& that) noexcept {
std::swap(this->fd_, that.fd_);
std::swap(this->writable_, that.writable_);
return *this;
}
~Val();
tr_sys_file_t fd_ = TR_BAD_SYS_FILE;

View File

@ -49,6 +49,7 @@
#include "torrent-metainfo.h"
#include "torrent.h"
#include "tr-assert.h"
#include "tr-assert.h"
#include "trevent.h" /* tr_runInEventThread() */
#include "utils.h"
#include "variant.h"
@ -1771,7 +1772,7 @@ static void torrentCallScript(tr_torrent const* tor, char const* script)
return;
}
auto torrent_dir = std::string{ tor->currentDir() };
auto torrent_dir = tr_pathbuf{ tor->currentDir() };
tr_sys_path_native_separators(std::data(torrent_dir));
auto const cmd = std::array<char const*, 2>{ script, nullptr };