From 377a14020db971af7b2a29f51421833de993eb7b Mon Sep 17 00:00:00 2001 From: Lucian Branescu Mihaila Date: Thu, 15 Jul 2010 00:26:29 +0000 Subject: Figure out mime-type for all files, not just executables and zips. Fix download errback. --- diff --git a/downloadmanager.py b/downloadmanager.py index f56d791..6e5a8c4 100644 --- a/downloadmanager.py +++ b/downloadmanager.py @@ -75,6 +75,7 @@ def remove_all_downloads(): class UserDownload(object): def __init__(self, download, activity_p): self._download = download + self._activity = activity_p self._source = download.get_uri() self._download.connect('notify::progress', self.__progress_change_cb) @@ -96,10 +97,6 @@ class UserDownload(object): if not os.path.exists(self._dest_uri): os.makedirs(self._dest_uri) - # FIXME - self._mime_type = 'image/jpeg' - self._activity = activity_p - # start download self._download.set_destination_uri(self._dest_uri) self._download.start() @@ -146,10 +143,10 @@ class UserDownload(object): self.dl_jobject.metadata['progress'] = '100' self.dl_jobject.file_path = self._dest_uri - if self._mime_type in ['application/octet-stream', - 'application/x-zip']: - sniffed_mime_type = mime.get_for_file(self._dest_uri) - self.dl_jobject.metadata['mime_type'] = sniffed_mime_type + #if self._mime_type in ['application/octet-stream', + # 'application/x-zip']: + sniffed_mime_type = mime.get_for_file(self._dest_uri) + self.dl_jobject.metadata['mime_type'] = sniffed_mime_type datastore.write(self.dl_jobject, transfer_ownership=True, @@ -160,7 +157,7 @@ class UserDownload(object): elif state == webkit.DOWNLOAD_STATUS_CANCELLED: self.cleanup_datastore_write() - def __error_cb(self, download, err_code, err_detail, reason, user_data): + def __error_cb(self, err_code, err_detail, reason, user_data): logging.debug("Error saving activity object to datastore: %s" % reason) self.cleanup_datastore_write() -- cgit v0.9.1