Changeset 0be6d8
- Timestamp:
- 09/25/2009 12:57:22 AM (16 years ago)
- Branches:
- 2.0.x, develop, extjs4-port, master
- Children:
- 66402b
- Parents:
- 7749f9
- Location:
- deluge/core
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
deluge/core/core.py
r7749f9 r0be6d8 316 316 from libtorrent's session status. 317 317 318 See: http://www.rasterbar.com/products/libtorrent/manual.html#status 319 318 320 :param keys: the keys for which we want values 319 321 :type keys: list … … 659 661 ie, plugin_file.read()""" 660 662 661 f = open(os.path.join( self.config["config_location"], "plugins", filename), "wb")663 f = open(os.path.join(deluge.configmanager.get_config_dir(), "plugins", filename), "wb") 662 664 f.write(plugin_data.data) 663 665 f.close() -
deluge/core/oldstateupgrader.py
r7749f9 r0be6d8 43 43 from deluge._libtorrent import lt 44 44 45 from deluge.configmanager import ConfigManager 45 from deluge.configmanager import ConfigManager, get_config_dir 46 46 import deluge.core.torrentmanager 47 47 from deluge.log import LOG as log … … 70 70 def __init__(self): 71 71 self.config = ConfigManager("core.conf") 72 self.state05_location = os.path.join( self.config["config_location"], "persistent.state")73 self.state10_location = os.path.join( self.config["state_location"], "torrents.state")72 self.state05_location = os.path.join(get_config_dir(), "persistent.state") 73 self.state10_location = os.path.join(get_config_dir(), "state", "torrents.state") 74 74 if os.path.exists(self.state05_location) and not os.path.exists(self.state10_location): 75 75 # If the 0.5 state file exists and the 1.0 doesn't, then let's upgrade it … … 90 90 new_state = deluge.core.torrentmanager.TorrentManagerState() 91 91 for ti, uid in state.torrents.items(): 92 torrent_path = os.path.join( self.config["config_location"], "torrentfiles", ti.filename)92 torrent_path = os.path.join(get_config_dir(), "torrentfiles", ti.filename) 93 93 try: 94 94 torrent_info = None … … 102 102 # Copy the torrent file to the new location 103 103 import shutil 104 shutil.copyfile(torrent_path, os.path.join( self.config["state_location"], str(torrent_info.info_hash()) + ".torrent"))104 shutil.copyfile(torrent_path, os.path.join(get_config_dir(), "state", str(torrent_info.info_hash()) + ".torrent")) 105 105 106 106 # Set the file prioritiy property if not already there … … 128 128 log.debug("Saving torrent state file.") 129 129 state_file = open( 130 os.path.join( self.config["state_location"], "torrents.state"), "wb")130 os.path.join(get_config_dir(), "state", "torrents.state"), "wb") 131 131 cPickle.dump(new_state, state_file) 132 132 state_file.close() -
deluge/core/preferencesmanager.py
r7749f9 r0be6d8 50 50 51 51 DEFAULT_PREFS = { 52 "config_location": deluge.configmanager.get_config_dir(),53 52 "send_info": False, 54 53 "info_sent": 0.0, … … 62 61 "torrentfiles_location": deluge.common.get_default_download_dir(), 63 62 "plugins_location": os.path.join(deluge.configmanager.get_config_dir(), "plugins"), 64 "state_location": os.path.join(deluge.configmanager.get_config_dir(), "state"),65 63 "prioritize_first_last_pieces": False, 66 64 "random_port": True, … … 159 157 self.config.register_set_function("torrentfiles_location", 160 158 self._on_set_torrentfiles_location) 161 self.config.register_set_function("state_location",162 self._on_set_state_location)163 159 self.config.register_set_function("listen_ports", 164 160 self._on_set_listen_ports) … … 247 243 log.debug("Unable to make directory: %s", e) 248 244 249 def _on_set_state_location(self, key, value):250 if not os.access(value, os.F_OK):251 try:252 os.makedirs(value)253 except Exception, e:254 log.debug("Unable to make directory: %s", e)255 256 245 def _on_set_listen_ports(self, key, value): 257 246 # Only set the listen ports if random_port is not true -
deluge/core/torrent.py
r7749f9 r0be6d8 43 43 import deluge.common 44 44 import deluge.component as component 45 from deluge.configmanager import ConfigManager 45 from deluge.configmanager import ConfigManager, get_config_dir 46 46 from deluge.log import LOG as log 47 47 from deluge.event import * … … 760 760 resume_data = lt.bencode(resume_data) 761 761 path = "%s/%s.fastresume" % ( 762 self.config["state_location"],762 os.path.join(get_config_dir(), "state"), 763 763 self.torrent_id) 764 764 try: … … 778 778 """Deletes the .fastresume file""" 779 779 path = "%s/%s.fastresume" % ( 780 self.config["state_location"],780 os.path.join(get_config_dir(), "state"), 781 781 self.torrent_id) 782 782 log.debug("Deleting fastresume file: %s", path) … … 789 789 """Writes the torrent file""" 790 790 path = "%s/%s.torrent" % ( 791 self.config["state_location"],791 os.path.join(get_config_dir(), "state"), 792 792 self.torrent_id) 793 793 log.debug("Writing torrent file: %s", path) … … 805 805 """Deletes the .torrent file in the state""" 806 806 path = "%s/%s.torrent" % ( 807 self.config["state_location"],807 os.path.join(get_config_dir(), "state"), 808 808 self.torrent_id) 809 809 log.debug("Deleting torrent file: %s", path) -
deluge/core/torrentmanager.py
r7749f9 r0be6d8 53 53 import deluge.common 54 54 import deluge.component as component 55 from deluge.configmanager import ConfigManager 55 from deluge.configmanager import ConfigManager, get_config_dir 56 56 from deluge.core.torrent import Torrent 57 57 from deluge.core.torrent import TorrentOptions … … 270 270 _file = open( 271 271 os.path.join( 272 self.config["state_location"],272 get_config_dir(), "state", 273 273 torrent_id + ".fastresume"), 274 274 "rb") … … 324 324 add_torrent_params["ti"] =\ 325 325 self.get_torrent_info_from_file( 326 os.path.join( self.config["state_location"], state.torrent_id + ".torrent"))326 os.path.join(get_config_dir(), "state", state.torrent_id + ".torrent")) 327 327 328 328 if not add_torrent_params["ti"]: … … 413 413 if filedump: 414 414 try: 415 save_file = open(os.path.join( self.config["state_location"],415 save_file = open(os.path.join(get_config_dir(), "state", 416 416 torrent.torrent_id + ".torrent"), 417 417 "wb") … … 450 450 _file = open( 451 451 os.path.join( 452 self.config["state_location"], torrent_id + ".torrent"),452 get_config_dir(), "state", torrent_id + ".torrent"), 453 453 "rb") 454 454 filedump = lt.bdecode(_file.read()) … … 463 463 """ 464 464 Remove a torrent from the session. 465 465 466 466 :param torrent_id: the torrent to remove 467 467 :type torrent_id: string 468 468 :param remove_data: if True, remove the downloaded data 469 469 :type remove_data: bool 470 470 471 471 :returns: True if removed successfully, False if not 472 472 :rtype: bool 473 473 474 474 :raises InvalidTorrentError: if the torrent_id is not in the session 475 475 476 476 """ 477 477 478 478 if torrent_id not in self.torrents: 479 479 raise InvalidTorrentError("torrent_id not in session") 480 480 481 481 # Emit the signal to the clients 482 482 component.get("EventManager").emit(PreTorrentRemovedEvent(torrent_id))
Note:
See TracChangeset
for help on using the changeset viewer.