incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [39/50] git commit: [#3154] ticket:410 used mkstemp with tmp file in export
Date Fri, 23 Aug 2013 16:58:39 GMT
[#3154]  ticket:410 used mkstemp with tmp file in export


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/1e053432
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/1e053432
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/1e053432

Branch: refs/heads/cj/6530
Commit: 1e053432d438942dbc90b390dac2cdd8ee19bc96
Parents: b154525
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Wed Aug 14 17:14:04 2013 +0400
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Thu Aug 22 20:04:45 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/project.py      | 3 ++-
 Allura/allura/tasks/export_tasks.py | 5 ++++-
 Allura/development.ini              | 1 +
 Allura/test.ini                     | 1 +
 4 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1e053432/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 41ea5c7..021bb47 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -866,7 +866,8 @@ class Project(MappedClass, ActivityNode, ActivityObject):
             shortname = self.shortname.split('/')[1]
         elif not self.is_root:
             shortname = self.shortname.split('/')[1]
-        return '%s.zip' % shortname
+
+        return config['bulk_export_filename'].format(project=shortname, date=datetime.utcnow())
 
     def bulk_export_status(self):
         fn = os.path.join(self.bulk_export_path(), self.bulk_export_filename())

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1e053432/Allura/allura/tasks/export_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index bbd4b1d..4b30c36 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -19,6 +19,7 @@ import json
 import os
 import logging
 import shutil
+from tempfile import mkstemp
 
 import tg
 from pylons import app_globals as g
@@ -61,9 +62,11 @@ def bulk_export(project_shortname, tools, username, neighborhood):
         log.info('Exporting %s...' % tool)
         try:
             path = create_export_dir(project)
-            with open(os.path.join(path, '%s.json' % tool), 'w') as f:
+            temp_name = mkstemp(dir=path)[1]
+            with open(temp_name, 'w') as f:
                 with h.push_context(project._id):
                     entry_to_export.bulk_export(f)
+            os.rename(temp_name, os.path.join(path, '%s.json' % tool))
         except:
             log.error('Something went wrong during export of %s' % tool, exc_info=True)
             not_exported_tools.append(tool)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1e053432/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index 0d3386b..ee9911b 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -143,6 +143,7 @@ scm.repos.tarball.url_prefix = http://localhost/
 scm.repos.tarball.zip_binary = /usr/bin/zip
 
 bulk_export_path = /tmp/bulk_export/{nbhd}/{project}
+bulk_export_filename = {project}-backup-{date:%Y-%m-%d-%H%M%S}.zip
 bulk_export_download_instructions = Sample instructions for {project}
 
 # space-separated list of tool names that are valid options

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1e053432/Allura/test.ini
----------------------------------------------------------------------
diff --git a/Allura/test.ini b/Allura/test.ini
index 9ce586e..2546149 100644
--- a/Allura/test.ini
+++ b/Allura/test.ini
@@ -103,6 +103,7 @@ scm.repos.tarball.root = /tmp/tarball
 scm.repos.tarball.url_prefix = file://
 
 bulk_export_path = /tmp/bulk_export/{nbhd}/{project}
+bulk_export_filename = {project}.zip
 bulk_export_download_instructions = Sample instructions for {project}
 
 support_tool_choices = wiki tickets discussion


Mime
View raw message