Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--downloadmanager.py20
-rwxr-xr-xwebactivity.py3
3 files changed, 18 insertions, 7 deletions
diff --git a/NEWS b/NEWS
index cf714f0..e153d5d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+* #2763: Save downloads to flash, not to /tmp. (tomeu)
+
37
* Add greek translation. (simosx)
diff --git a/downloadmanager.py b/downloadmanager.py
index fcafad2..ed0b0f1 100644
--- a/downloadmanager.py
+++ b/downloadmanager.py
@@ -31,10 +31,14 @@ from sugar import profile
from sugar import objects
_browser = None
-def init(browser):
+_temp_path = '/tmp'
+def init(browser, temp_path):
global _browser
_browser = browser
+ global _temp_path
+ _temp_path = temp_path
+
_active_ds_writes = 0
_quit_callback = None
@@ -52,11 +56,15 @@ class DownloadManager:
file_class = components.classes["@mozilla.org/file/local;1"]
dest_file = file_class.createInstance(interfaces.nsILocalFile)
- if default_file:
- file_path = os.path.join(tempfile.gettempdir(), default_file)
- else:
- f, file_path = tempfile.mkstemp(suggested_file_extension)
- del f
+ if not default_file:
+ default_file = time.time()
+ if suggested_file_extension:
+ default_file = '%s.%s' % (default_file, suggested_file_extension)
+
+ global _temp_path
+ if not os.path.exists(_temp_path):
+ os.makedirs(_temp_path)
+ file_path = os.path.join(_temp_path, default_file)
dest_file.initWithPath(file_path)
diff --git a/webactivity.py b/webactivity.py
index 6ebeb98..0b3cfa4 100755
--- a/webactivity.py
+++ b/webactivity.py
@@ -52,7 +52,8 @@ class WebActivity(activity.Activity):
self.set_canvas(self._browser)
self._browser.show()
- downloadmanager.init(self._browser)
+ temp_path = os.path.join(self.get_activity_root(), 'tmp')
+ downloadmanager.init(self._browser, temp_path)
sessionhistory.init(self._browser)
progresslistener.init(self._browser)