Apply remaining changes

Co-authored-by: rakshasa <475125+rakshasa@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-10-19 22:20:32 +00:00
committed by GitHub
parent 7a38112149
commit d47ce9d129
9 changed files with 70 additions and 10 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ TestSessionCommit::commit_and_verify(bool use_fsyncdisk) {
std::stringstream rtorrent_stream("rtorrent-data");
std::stringstream libtorrent_stream("libtorrent-data");
session::DownloadStorer::save_and_move_streams(path, use_fsyncdisk, &torrent_stream, &rtorrent_stream, &libtorrent_stream);
session::DownloadStorer::save_and_move_streams(path, use_fsyncdisk, 0600, &torrent_stream, &rtorrent_stream, &libtorrent_stream);
CPPUNIT_ASSERT_EQUAL(std::string("torrent-data"), read_file(path));
CPPUNIT_ASSERT_EQUAL(std::string("rtorrent-data"), read_file(path + ".rtorrent"));
+17 -2
View File
@@ -39,12 +39,12 @@ read_file(const std::string& path) {
}
void
save_session_files(const std::string& path) {
save_session_files(const std::string& path, mode_t file_mode = 0600) {
std::stringstream torrent_stream("torrent-data");
std::stringstream rtorrent_stream("rtorrent-data");
std::stringstream libtorrent_stream("libtorrent-data");
session::DownloadStorer::save_and_move_streams(path, false, &torrent_stream, &rtorrent_stream, &libtorrent_stream);
session::DownloadStorer::save_and_move_streams(path, false, file_mode, &torrent_stream, &rtorrent_stream, &libtorrent_stream);
}
unsigned int
@@ -130,6 +130,21 @@ TestSessionStorer::test_saved_files_are_owner_only() {
CPPUNIT_ASSERT_EQUAL(0600u, permissions_of(path + ".libtorrent_resume"));
}
void
TestSessionStorer::test_saved_files_use_configured_mode() {
for (mode_t mode : {0660, 0640}) {
auto path = m_session_dir + "/" + entry_name;
auto prev_umask = ::umask(0);
save_session_files(path, mode);
::umask(prev_umask);
CPPUNIT_ASSERT_EQUAL((unsigned int)mode, permissions_of(path));
CPPUNIT_ASSERT_EQUAL((unsigned int)mode, permissions_of(path + ".rtorrent"));
CPPUNIT_ASSERT_EQUAL((unsigned int)mode, permissions_of(path + ".libtorrent_resume"));
}
}
// Entries listed for loading must report their real type so that a symlink in
// the session directory is skipped instead of loaded.
void
+2
View File
@@ -7,6 +7,7 @@ class TestSessionStorer : public test_fixture {
CPPUNIT_TEST(test_temp_file_symlink_is_not_followed);
CPPUNIT_TEST(test_saved_files_are_owner_only);
CPPUNIT_TEST(test_saved_files_use_configured_mode);
CPPUNIT_TEST(test_symlinked_entry_is_not_a_file);
CPPUNIT_TEST_SUITE_END();
@@ -17,6 +18,7 @@ public:
void test_temp_file_symlink_is_not_followed();
void test_saved_files_are_owner_only();
void test_saved_files_use_configured_mode();
void test_symlinked_entry_is_not_a_file();
private: