add move to different partition
This commit is contained in:
parent
228597abdc
commit
bc8e6b441f
|
@ -252,6 +252,53 @@ namespace
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
template <class Path>
|
||||||
|
void recursive_copy(Path const& old_path, Path const& new_path, std::string& error)
|
||||||
|
{
|
||||||
|
using boost::filesystem::directory_iterator;
|
||||||
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
|
try {
|
||||||
|
#endif
|
||||||
|
TORRENT_ASSERT(error.empty());
|
||||||
|
if (is_directory(old_path))
|
||||||
|
{
|
||||||
|
create_directory(new_path);
|
||||||
|
for (directory_iterator i(old_path), end; i != end; ++i)
|
||||||
|
{
|
||||||
|
recursive_copy(i->path(), new_path / i->leaf(), error);
|
||||||
|
if (!error.empty()) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
copy_file(old_path, new_path);
|
||||||
|
}
|
||||||
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
|
} catch (std::exception& e) { error = e.what(); }
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Path>
|
||||||
|
void recursive_remove(Path const& old_path)
|
||||||
|
{
|
||||||
|
using boost::filesystem::directory_iterator;
|
||||||
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
|
try {
|
||||||
|
#endif
|
||||||
|
if (is_directory(old_path))
|
||||||
|
{
|
||||||
|
for (directory_iterator i(old_path), end; i != end; ++i)
|
||||||
|
recursive_remove(i->path());
|
||||||
|
remove(old_path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
remove(old_path);
|
||||||
|
}
|
||||||
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
|
} catch (std::exception& e) {}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
std::vector<std::pair<size_type, std::time_t> > get_filesizes(
|
std::vector<std::pair<size_type, std::time_t> > get_filesizes(
|
||||||
torrent_info const& t, fs::path p)
|
torrent_info const& t, fs::path p)
|
||||||
{
|
{
|
||||||
|
@ -667,8 +714,17 @@ namespace libtorrent
|
||||||
m_save_path = save_path;
|
m_save_path = save_path;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (std::exception&) {}
|
catch (std::exception& e)
|
||||||
return false;
|
{
|
||||||
|
std::string err;
|
||||||
|
recursive_copy(old_path, new_path, err);
|
||||||
|
if (!err.empty())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
m_save_path = save_path;
|
||||||
|
recursive_remove(old_path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
|
|
@ -23,7 +23,7 @@ plugin_description = _("This plugin allows users to move the torrent to a \
|
||||||
different directory without having to remove and re-add the torrent. This \
|
different directory without having to remove and re-add the torrent. This \
|
||||||
feature can be found by right-clicking on a torrent.\nFurthermore, it \
|
feature can be found by right-clicking on a torrent.\nFurthermore, it \
|
||||||
allows the user to automatically have finished torrents moved to a different \
|
allows the user to automatically have finished torrents moved to a different \
|
||||||
folder.\nNote: Files can currently only be moved within the same partition")
|
folder.")
|
||||||
|
|
||||||
def deluge_init(deluge_path):
|
def deluge_init(deluge_path):
|
||||||
global path
|
global path
|
||||||
|
@ -130,7 +130,7 @@ class movetorrentMenu:
|
||||||
def handle_event(self, event):
|
def handle_event(self, event):
|
||||||
if event['event_type'] is self.core.constants['EVENT_STORAGE_MOVED']:
|
if event['event_type'] is self.core.constants['EVENT_STORAGE_MOVED']:
|
||||||
if event['message'] == self.core.unique_IDs[event['unique_ID']].save_dir:
|
if event['message'] == self.core.unique_IDs[event['unique_ID']].save_dir:
|
||||||
self.dialogs.show_popup_warning(self.window, _("You cannot move torrent to a different partition. Please check your preferences. Also, you cannot move a torrent's files to the same directory that they are already stored or move a torrent's files before any of its files have actually been created."))
|
self.dialogs.show_popup_warning(self.window, "An error occured while trying to move the torrent. Please check your permissions and note that you cannot move a torrent's files to the same directory that they are already stored or move a torrent's files before any of its files have actually been created."))
|
||||||
self.core.unique_IDs[event['unique_ID']].save_dir = event['message']
|
self.core.unique_IDs[event['unique_ID']].save_dir = event['message']
|
||||||
self.core.pickle_state()
|
self.core.pickle_state()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue