mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-03 15:13:23 +00:00
Fix some issues with creating torrent files, was putting the announce list in the wrong key
Add support for using a system installed GeoIP db file. It will look for /usr/share/GeoIP/GeoIP.dat first and try to load that
This commit is contained in:
parent
49e27a33bf
commit
a24c07a9bd
@ -65,7 +65,7 @@ class AlertManager(component.Component):
|
||||
lt.alert.category_t.storage_notification |
|
||||
lt.alert.category_t.tracker_notification |
|
||||
lt.alert.category_t.status_notification |
|
||||
lt.alert.category_t.ip_block_notification|
|
||||
lt.alert.category_t.ip_block_notification |
|
||||
lt.alert.category_t.performance_warning)
|
||||
|
||||
# handlers is a dictionary of lists {"alert_type": [handler1,h2,..]}
|
||||
|
@ -95,16 +95,6 @@ class Core(component.Component):
|
||||
# Load the session state if available
|
||||
self.__load_session_state()
|
||||
|
||||
# Load the GeoIP DB for country look-ups if available
|
||||
geoip_db = pkg_resources.resource_filename("deluge", os.path.join("data", "GeoIP.dat"))
|
||||
if os.path.exists(geoip_db):
|
||||
try:
|
||||
self.session.load_country_db(geoip_db)
|
||||
except Exception, e:
|
||||
log.error("Unable to load geoip database!")
|
||||
log.exception(e)
|
||||
|
||||
|
||||
# Set the user agent
|
||||
self.settings = lt.session_settings()
|
||||
self.settings.user_agent = "Deluge %s" % deluge.common.get_version()
|
||||
@ -141,6 +131,22 @@ class Core(component.Component):
|
||||
# Get the core config
|
||||
self.config = deluge.configmanager.ConfigManager("core.conf")
|
||||
|
||||
# Load the GeoIP DB for country look-ups if available
|
||||
geoip_db = ""
|
||||
if os.path.exists(self.config["geoip_db_location"]):
|
||||
geoip_db = self.config["geoip_db_location"]
|
||||
elif os.path.exists(pkg_resources.resource_filename("deluge", os.path.join("data", "GeoIP.dat"))):
|
||||
geoip_db = pkg_resources.resource_filename("deluge", os.path.join("data", "GeoIP.dat"))
|
||||
else:
|
||||
log.warning("Unable to find GeoIP database file!")
|
||||
|
||||
if geoip_db:
|
||||
try:
|
||||
self.session.load_country_db(geoip_db)
|
||||
except Exception, e:
|
||||
log.error("Unable to load geoip database!")
|
||||
log.exception(e)
|
||||
|
||||
# If there was an interface value from the command line, use it, but
|
||||
# store the one in the config so we can restore it on shutdown
|
||||
self.__old_interface = None
|
||||
@ -626,7 +632,7 @@ class Core(component.Component):
|
||||
|
||||
@export
|
||||
def create_torrent(self, path, tracker, piece_length, comment, target,
|
||||
url_list, private, created_by, httpseeds, add_to_session):
|
||||
url_list, private, created_by, httpseeds, trackers, add_to_session):
|
||||
|
||||
log.debug("creating torrent..")
|
||||
threading.Thread(target=_create_torrent_thread,
|
||||
@ -640,10 +646,11 @@ class Core(component.Component):
|
||||
private,
|
||||
created_by,
|
||||
httpseeds,
|
||||
trackers,
|
||||
add_to_session)).start()
|
||||
|
||||
def _create_torrent_thread(self, path, tracker, piece_length, comment, target,
|
||||
url_list, private, created_by, httpseeds, add_to_session):
|
||||
url_list, private, created_by, httpseeds, trackers, add_to_session):
|
||||
import deluge.metafile
|
||||
deluge.metafile.make_meta_file(
|
||||
path,
|
||||
@ -654,7 +661,8 @@ class Core(component.Component):
|
||||
url_list=url_list,
|
||||
private=private,
|
||||
created_by=created_by,
|
||||
httpseeds=httpseeds)
|
||||
httpseeds=httpseeds,
|
||||
trackers=trackers)
|
||||
log.debug("torrent created!")
|
||||
if add_to_session:
|
||||
self.add_torrent_file(os.path.split(target)[1], open(target, "rb").read(), None)
|
||||
|
@ -142,7 +142,8 @@ DEFAULT_PREFS = {
|
||||
"outgoing_ports": [0, 0],
|
||||
"random_outgoing_ports": True,
|
||||
"peer_tos": "0x00",
|
||||
"rate_limit_ip_overhead": True
|
||||
"rate_limit_ip_overhead": True,
|
||||
"geoip_db_location": "/usr/share/GeoIP/GeoIP.dat"
|
||||
}
|
||||
|
||||
class PreferencesManager(component.Component):
|
||||
|
@ -58,7 +58,7 @@ def dummy(v):
|
||||
def make_meta_file(path, url, piece_length, progress=dummy,
|
||||
title=None, comment=None, safe=None, content_type=None,
|
||||
target=None, url_list=None, name=None, private=False,
|
||||
created_by=None, httpseeds=None):
|
||||
created_by=None, httpseeds=None, trackers=None):
|
||||
data = {'creation date': int(gmtime())}
|
||||
if url:
|
||||
data['announce'] = url.strip()
|
||||
@ -88,6 +88,8 @@ def make_meta_file(path, url, piece_length, progress=dummy,
|
||||
data['created by'] = created_by
|
||||
if httpseeds:
|
||||
data['httpseeds'] = httpseeds
|
||||
if trackers:
|
||||
data['announce-list'] = trackers
|
||||
|
||||
h.write(bencode(data))
|
||||
h.close()
|
||||
|
@ -288,10 +288,11 @@ class CreateTorrentDialog:
|
||||
piece_length,
|
||||
comment,
|
||||
result,
|
||||
trackers,
|
||||
None,
|
||||
private,
|
||||
author,
|
||||
webseeds,
|
||||
trackers,
|
||||
add_to_session)
|
||||
|
||||
else:
|
||||
@ -312,13 +313,14 @@ class CreateTorrentDialog:
|
||||
private,
|
||||
author,
|
||||
webseeds,
|
||||
trackers,
|
||||
add_to_session)).start()
|
||||
|
||||
chooser.destroy()
|
||||
self.dialog.destroy()
|
||||
|
||||
def create_torrent(self, path, tracker, piece_length, progress, comment, target,
|
||||
url_list, private, created_by, httpseeds, add_to_session):
|
||||
url_list, private, created_by, httpseeds, trackers, add_to_session):
|
||||
import deluge.metafile
|
||||
deluge.metafile.make_meta_file(
|
||||
path,
|
||||
@ -330,7 +332,8 @@ class CreateTorrentDialog:
|
||||
url_list=url_list,
|
||||
private=private,
|
||||
created_by=created_by,
|
||||
httpseeds=httpseeds)
|
||||
httpseeds=httpseeds,
|
||||
trackers=trackers)
|
||||
self.glade.get_widget("progress_dialog").hide_all()
|
||||
if add_to_session:
|
||||
client.core.add_torrent_file(
|
||||
|
Loading…
x
Reference in New Issue
Block a user