Codebase list sugar-read-activity / 392ccca
Don't set path in the downloader Gonzalo Odiard 10 years ago
1 changed file(s) with 3 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
842842 self._progress_alert = None
843843 GObject.idle_add(self._get_document)
844844
845 def _download_document(self, tube_id, path):
845 def _download_document(self, tube_id):
846846 # FIXME: should ideally have the CM listen on a Unix socket
847847 # instead of IPv4 (might be more compatible with Rainbow)
848848 chan = self.shared_activity.telepathy_tubes_chan
866866 getter.connect("finished", self._download_result_cb, tube_id)
867867 getter.connect("progress", self._download_progress_cb, tube_id)
868868 getter.connect("error", self._download_error_cb, tube_id)
869 _logger.debug("Starting download to %s...", path)
870 getter.start(path)
869 getter.start()
871870 self._download_content_length = getter.get_content_length()
872871 self._download_content_type = getter.get_content_type()
873872 return False
875874 def _get_document(self):
876875 if not self._want_document:
877876 return False
878
879 # Assign a file path to download if one doesn't exist yet
880 if not self._jobject.file_path:
881 path = os.path.join(self.get_activity_root(), 'instance',
882 'tmp%i' % time.time())
883 else:
884 path = self._jobject.file_path
885877
886878 # Pick an arbitrary tube we can try to download the document from
887879 try:
893885
894886 # Avoid trying to download the document multiple times at once
895887 self._want_document = False
896 GObject.idle_add(self._download_document, tube_id, path)
888 GObject.idle_add(self._download_document, tube_id)
897889 return False
898890
899891 def _joined_cb(self, also_self):