allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [allura] 01/02: [#8333] unicode fixes for tarball snapshots
Date Fri, 31 Jan 2020 16:11:50 GMT
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit be453d4bb30cf75aec14bfa30b9ebf94272b94ad
Author: Dave Brondsema <dave@brondsema.net>
AuthorDate: Fri Jan 31 10:42:54 2020 -0500

    [#8333] unicode fixes for tarball snapshots
---
 Allura/allura/controllers/repository.py | 4 ++--
 Allura/allura/model/repository.py       | 4 ++--
 Allura/allura/tests/unit/test_repo.py   | 2 +-
 ForgeSVN/forgesvn/model/svn.py          | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 225ea97..7437df3 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -717,7 +717,7 @@ class CommitBrowser(BaseController):
         status = c.app.repo.get_tarball_status(rev, path)
         if not status and request.method == 'POST':
             allura.tasks.repo_tasks.tarball.post(rev, path)
-            redirect(('tarball' + u'?path={0}'.format(path) if path else '').encode('utf-8'))
+            redirect('tarball?path={0}'.format(h.urlquote(path) if path else ''))
         return dict(commit=self._commit, revision=rev, status=status)
 
     @expose('json:')
@@ -777,7 +777,7 @@ class TreeBrowser(BaseController, DispatchIndex):
         tool_subscribed = M.Mailbox.subscribed()
         tarball_url = None
         if asbool(tg.config.get('scm.repos.tarball.enable', False)):
-            cutout = len('tree' + self._path.encode('utf8'))
+            cutout = len(b'tree' + self._path.encode('utf8'))
             if request.path.endswith('/') and not self._path.endswith('/'):
                 cutout += 1
             tarball_url = h.urlquote('%starball' % unquote(request.path)[:-cutout])
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 5507356..d4708d1 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -430,7 +430,7 @@ class Repository(Artifact, ActivityObject):
         pathname = os.path.join(
             self.tarball_path, self.tarball_filename(revision, path))
         filename = '%s%s' % (pathname, '.zip')
-        if os.path.isfile(filename):
+        if os.path.isfile(filename.encode('utf-8')):
             return 'complete'
 
         # file doesn't exist, check for busy task
@@ -1938,7 +1938,7 @@ def zipdir(source, zipfile, exclude=None):
     # this is needed to get proper prefixes inside zip-file
     working_dir = os.path.dirname(source)
     source_fn = os.path.basename(source)
-    command = [zipbin, '-y', '-q', '-r', zipfile, source_fn]
+    command = [zipbin, '-y', '-q', '-r', zipfile, source_fn.encode('utf-8')]
     if exclude:
         command += ['-x', exclude]
     p = Popen(command, cwd=working_dir, stdout=PIPE, stderr=PIPE)
diff --git a/Allura/allura/tests/unit/test_repo.py b/Allura/allura/tests/unit/test_repo.py
index 83827e5..792d5e5 100644
--- a/Allura/allura/tests/unit/test_repo.py
+++ b/Allura/allura/tests/unit/test_repo.py
@@ -281,7 +281,7 @@ class TestZipDir(unittest.TestCase):
         self.assertIn(
             "Command: " +
             ("['/bin/zip', '-y', '-q', '-r', '/fake/zip/file.tmp', 'repo'] " if six.PY3 else
-             "[u'/bin/zip', u'-y', u'-q', u'-r', u'/fake/zip/file.tmp', u'repo'] ") +
+             "[u'/bin/zip', u'-y', u'-q', u'-r', u'/fake/zip/file.tmp', 'repo'] ") +
             "returned non-zero exit code 1", emsg)
         self.assertTrue("STDOUT: 1" in emsg)
         self.assertTrue("STDERR: 2" in emsg)
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index b8c835c..4f7560a 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -695,8 +695,8 @@ class SVNImplementation(M.RepositoryImplementation):
         archive_name = self._repo.tarball_filename(commit, path)
         dest = os.path.join(self._repo.tarball_path, archive_name)
         tmpdest = os.path.join(self._repo.tarball_tmpdir, archive_name)
-        filename = os.path.join(self._repo.tarball_path, '%s%s' % (archive_name, '.zip'))
-        tmpfilename = os.path.join(self._repo.tarball_path, '%s%s' % (archive_name, '.tmp'))
+        filename = os.path.join(self._repo.tarball_path, '%s%s' % (archive_name, '.zip')).encode('utf-8')
+        tmpfilename = os.path.join(self._repo.tarball_path, '%s%s' % (archive_name, '.tmp')).encode('utf-8')
         rmtree(dest.encode('utf8'), ignore_errors=True)  # must encode into bytes or it'll
fail on non-ascii filenames
         rmtree(tmpdest.encode('utf8'), ignore_errors=True)
         path = os.path.join(self._url, path)


Mime
View raw message