Changeset 0be6d8


Ignore:
Timestamp:
09/25/2009 12:57:22 AM (16 years ago)
Author:
Andrew Resch <andrewresch@gmail.com>
Branches:
2.0.x, develop, extjs4-port, master
Children:
66402b
Parents:
7749f9
Message:

Remove 'state_location' and 'config_location' preferences and all references from the code. We should use configmanager.get_config_dir() instead.

Location:
deluge/core
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • deluge/core/core.py

    r7749f9 r0be6d8  
    316316        from libtorrent's session status.
    317317
     318        See: http://www.rasterbar.com/products/libtorrent/manual.html#status
     319
    318320        :param keys: the keys for which we want values
    319321        :type keys: list
     
    659661        ie, plugin_file.read()"""
    660662
    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")
    662664        f.write(plugin_data.data)
    663665        f.close()
  • deluge/core/oldstateupgrader.py

    r7749f9 r0be6d8  
    4343from deluge._libtorrent import lt
    4444
    45 from deluge.configmanager import ConfigManager
     45from deluge.configmanager import ConfigManager, get_config_dir
    4646import deluge.core.torrentmanager
    4747from deluge.log import LOG as log
     
    7070    def __init__(self):
    7171        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")
    7474        if os.path.exists(self.state05_location) and not os.path.exists(self.state10_location):
    7575            # If the 0.5 state file exists and the 1.0 doesn't, then let's upgrade it
     
    9090        new_state = deluge.core.torrentmanager.TorrentManagerState()
    9191        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)
    9393            try:
    9494                torrent_info = None
     
    102102            # Copy the torrent file to the new location
    103103            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"))
    105105
    106106            # Set the file prioritiy property if not already there
     
    128128            log.debug("Saving torrent state file.")
    129129            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")
    131131            cPickle.dump(new_state, state_file)
    132132            state_file.close()
  • deluge/core/preferencesmanager.py

    r7749f9 r0be6d8  
    5050
    5151DEFAULT_PREFS = {
    52     "config_location": deluge.configmanager.get_config_dir(),
    5352    "send_info": False,
    5453    "info_sent": 0.0,
     
    6261    "torrentfiles_location": deluge.common.get_default_download_dir(),
    6362    "plugins_location": os.path.join(deluge.configmanager.get_config_dir(), "plugins"),
    64     "state_location": os.path.join(deluge.configmanager.get_config_dir(), "state"),
    6563    "prioritize_first_last_pieces": False,
    6664    "random_port": True,
     
    159157        self.config.register_set_function("torrentfiles_location",
    160158            self._on_set_torrentfiles_location)
    161         self.config.register_set_function("state_location",
    162             self._on_set_state_location)
    163159        self.config.register_set_function("listen_ports",
    164160            self._on_set_listen_ports)
     
    247243                log.debug("Unable to make directory: %s", e)
    248244
    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 
    256245    def _on_set_listen_ports(self, key, value):
    257246        # Only set the listen ports if random_port is not true
  • deluge/core/torrent.py

    r7749f9 r0be6d8  
    4343import deluge.common
    4444import deluge.component as component
    45 from deluge.configmanager import ConfigManager
     45from deluge.configmanager import ConfigManager, get_config_dir
    4646from deluge.log import LOG as log
    4747from deluge.event import *
     
    760760        resume_data = lt.bencode(resume_data)
    761761        path = "%s/%s.fastresume" % (
    762             self.config["state_location"],
     762            os.path.join(get_config_dir(), "state"),
    763763            self.torrent_id)
    764764        try:
     
    778778        """Deletes the .fastresume file"""
    779779        path = "%s/%s.fastresume" % (
    780             self.config["state_location"],
     780            os.path.join(get_config_dir(), "state"),
    781781            self.torrent_id)
    782782        log.debug("Deleting fastresume file: %s", path)
     
    789789        """Writes the torrent file"""
    790790        path = "%s/%s.torrent" % (
    791             self.config["state_location"],
     791            os.path.join(get_config_dir(), "state"),
    792792            self.torrent_id)
    793793        log.debug("Writing torrent file: %s", path)
     
    805805        """Deletes the .torrent file in the state"""
    806806        path = "%s/%s.torrent" % (
    807             self.config["state_location"],
     807            os.path.join(get_config_dir(), "state"),
    808808            self.torrent_id)
    809809        log.debug("Deleting torrent file: %s", path)
  • deluge/core/torrentmanager.py

    r7749f9 r0be6d8  
    5353import deluge.common
    5454import deluge.component as component
    55 from deluge.configmanager import ConfigManager
     55from deluge.configmanager import ConfigManager, get_config_dir
    5656from deluge.core.torrent import Torrent
    5757from deluge.core.torrent import TorrentOptions
     
    270270            _file = open(
    271271                os.path.join(
    272                     self.config["state_location"],
     272                    get_config_dir(), "state",
    273273                    torrent_id + ".fastresume"),
    274274                    "rb")
     
    324324                add_torrent_params["ti"] =\
    325325                    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"))
    327327
    328328                if not add_torrent_params["ti"]:
     
    413413        if filedump:
    414414            try:
    415                 save_file = open(os.path.join(self.config["state_location"],
     415                save_file = open(os.path.join(get_config_dir(), "state",
    416416                        torrent.torrent_id + ".torrent"),
    417417                        "wb")
     
    450450            _file = open(
    451451                os.path.join(
    452                     self.config["state_location"], torrent_id + ".torrent"),
     452                    get_config_dir(), "state", torrent_id + ".torrent"),
    453453                        "rb")
    454454            filedump = lt.bdecode(_file.read())
     
    463463        """
    464464        Remove a torrent from the session.
    465        
     465
    466466        :param torrent_id: the torrent to remove
    467467        :type torrent_id: string
    468468        :param remove_data: if True, remove the downloaded data
    469469        :type remove_data: bool
    470        
     470
    471471        :returns: True if removed successfully, False if not
    472472        :rtype: bool
    473        
     473
    474474        :raises InvalidTorrentError: if the torrent_id is not in the session
    475        
     475
    476476        """
    477        
     477
    478478        if torrent_id not in self.torrents:
    479479            raise InvalidTorrentError("torrent_id not in session")
    480            
     480
    481481        # Emit the signal to the clients
    482482        component.get("EventManager").emit(PreTorrentRemovedEvent(torrent_id))
Note: See TracChangeset for help on using the changeset viewer.