* Fixed the log redraw which didn't happen as the display's scheduler

didn't get re-added to the task scheduler until a new event happened.

* Added redraw delay interval of 100ms, consider 50ms.

* Removed exceptions from core::DownloadStore::save.

* Added load, load_run, tied_stop and tied_remove to man-page.

* Cleaned up the command/option instances, move them to Control.

* PCB::load_up_chunk grabbed the errno from m_downChunk, not m_upChunk.

* Various string operations were moved to rak/string_manip.h.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@617 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-01-06 21:14:49 +00:00
parent 4431fd1652
commit f32c15878a
33 changed files with 471 additions and 482 deletions
+15 -9
View File
@@ -34,16 +34,18 @@
// Skomakerveien 33
// 3185 Skoppum, NORWAY
// DownloadStore handles the saving and listing of session torrents.
#include "config.h"
#include <fstream>
#include <stdexcept>
#include <stdio.h>
#include <unistd.h>
#include <rak/string_manip.h>
#include <torrent/bencode.h>
#include <torrent/exceptions.h>
#include <torrent/torrent.h>
#include "utils/parse.h"
#include "download.h"
#include "download_store.h"
@@ -62,15 +64,19 @@ DownloadStore::save(Download* d) {
if (!is_active())
return;
std::fstream f(create_filename(d).c_str(), std::ios::out | std::ios::trunc);
std::fstream f((create_filename(d) + ".new").c_str(), std::ios::out | std::ios::trunc);
if (!f.is_open())
throw std::runtime_error("core::DownloadStore::save(...) could not open file");
return;
f << d->get_bencode();
if (f.fail())
throw std::runtime_error("core::DownloadStore::save(...) could not write torrent");
return;
f.close();
::rename((create_filename(d) + ".new").c_str(), create_filename(d).c_str());
}
void
@@ -78,7 +84,7 @@ DownloadStore::remove(Download* d) {
if (!is_active())
return;
unlink(create_filename(d).c_str());
::unlink(create_filename(d).c_str());
}
utils::Directory
@@ -89,7 +95,7 @@ DownloadStore::get_formated_entries() {
utils::Directory d(m_path);
if (!d.update())
throw std::runtime_error("core::DownloadStore::update() could not open directory \"" + m_path + "\"");
throw torrent::storage_error("core::DownloadStore::update() could not open directory \"" + m_path + "\"");
d.erase(std::remove_if(d.begin(), d.end(), std::not1(std::ptr_fun(&DownloadStore::is_correct_format))), d.end());
@@ -111,7 +117,7 @@ DownloadStore::is_correct_format(std::string f) {
std::string
DownloadStore::create_filename(Download* d) {
return m_path + utils::string_to_hex(d->get_hash()) + ".torrent";
return m_path + rak::transform_hex(d->get_hash()) + ".torrent";
}
}
+2 -2
View File
@@ -180,7 +180,7 @@ Manager::erase(DListItr itr) {
void
Manager::start(Download* d, bool printLog) {
try {
d->get_bencode().get_key("rtorrent").get_key("state") = "started";
d->get_bencode().get_key("rtorrent").insert_key("state", "started");
if (d->get_download().is_active())
return;
@@ -205,7 +205,7 @@ Manager::start(Download* d, bool printLog) {
void
Manager::stop(Download* d) {
try {
d->get_bencode().get_key("rtorrent").get_key("state") = "stopped";
d->get_bencode().get_key("rtorrent").insert_key("state", "stopped");
m_downloadList.stop(d);