diff options
author | Tomeu Vizoso <tomeu@tomeuvizoso.net> | 2007-08-13 19:18:46 (GMT) |
---|---|---|
committer | Tomeu Vizoso <tomeu@tomeuvizoso.net> | 2007-08-13 19:18:46 (GMT) |
commit | c58d48910bafe2fd783463f6538f450f54fa3e87 (patch) | |
tree | ff3dcca15baf9bcc45fb6831f5170f7739ffa398 /downloadmanager.py | |
parent | d4ddf8d01339a7cee577f354d317273cce13c884 (diff) |
#2763: Save downloads to flash, not to /tmp.
Diffstat (limited to 'downloadmanager.py')
-rw-r--r-- | downloadmanager.py | 20 |
1 files changed, 14 insertions, 6 deletions
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) |