Edgewall Software

Ticket #238 (closed enhancement: fixed)

Opened 5 years ago

Last modified 3 weeks ago

Support for downloading tarballs from the repository

Reported by: cathelijne@… Owned by: cboos
Priority: normal Milestone: 0.10
Component: version control/browser Version: 0.6
Severity: minor Keywords: objectstore tracdiff
Cc: athomas

Description

It would be cool to be able to browse the repository and download a tarball of a branch or tag.

Attachments

Change History

Changed 4 years ago by daniel

While presumable a cool feature, it'll possibly take up a lot of resources and bandwidth.

If done though, adding a "download directory as tar/zip-ball" feature to the Browser would suffice.

Changed 4 years ago by daniel

  • priority changed from normal to lowest
  • milestone set to 0.8

Changed 4 years ago by daniel

  • summary changed from Support for extracting tarballs from the repository to Support for downloading tarballs from the repository
  • milestone changed from 0.8 to 0.9

Changed 4 years ago by cmlenz

#814 marked as duplicate of this ticket.

Changed 4 years ago by cmlenz

  • keywords helpwanted added

This shouldn't be so hard... have a look at the zip file support in Changeset.py for an example of how to package up files in a ZIP file.

Changed 3 years ago by cmlenz

#1504 has been marked as duplicate of this ticket (although it limits the request to files as opposed to whole directories). It also contains a patch for enabling this.

Changed 3 years ago by cboos

Note that this feature would also solve #763.

Changed 3 years ago by cboos

  • owner changed from jonas to cboos
  • status changed from new to assigned

This is implemented in the TracDiff branch.

Changed 3 years ago by cboos

  • priority changed from lowest to normal
  • severity changed from normal to minor
  • milestone changed from 0.9 to 1.0

This will be post-poned to 1.0, as this is part of the TracDiff branch.

Changed 3 years ago by cboos

This ticket depends on #2028. Go there for the patches against 0.9.x.

Changed 3 years ago by cboos

mgood suggested that this feature could put some load on the server. While that's certainly not an issue with small repositories, that can be a problem for big repositories, so it should be possible to disable this feature:

[browser]
download_archive = false

However, a better solution might be to allow the download of some selected paths and cache the corresponding .zip files:

[browser]
restrict_download = tags/trac-0.8.1, tags/trac-0.8.4, tags/trac-0.9b1

Of course, the revision should be taken into account, which may complicate matters (e.g. cache a maximum of 5 different revisions for each specified path).

Changed 3 years ago by cboos

  • keywords tracdiff added

Changed 3 years ago by ttest

I don't know if it would be a good idea to restrict the downloadable directories in the configuration file, since than you would have information in there about the structure of your repository. IMHO it would be better to put the information which directories are downloadable/not downloadable in the repo. itself. Properties would be perfect for this.

Changed 3 years ago by cboos

  • milestone changed from 1.0 to 0.10

answering ttest: not every VersioningSystemBackend has support for properties (e.g. Mercurial doesn't)

Changed 3 years ago by anonymous

  • priority changed from normal to high

Changed 3 years ago by anonymous

  • priority changed from high to normal

Changed 3 years ago by cboos

Note that the feature is now available in trunk. I leave this open until there's some consensus about the form that should take the "control" of this feature. What we have so far:

  • usage of properties is ruled out because that would be specific to TracSubversion
  • some possible TracIni settingss:
    • enable_download for enabling or not that feature
    • restrict_download using a glob pattern to define the paths where a download is possible. e.g.
      • "*":: everywhere
      • "tags/*":: only below the tags folder
      • "":: nowhere

Changed 3 years ago by cboos

Implementation of the previous idea (list of glob patterns)

Index: trac/versioncontrol/web_ui/browser.py
===================================================================
--- trac/versioncontrol/web_ui/browser.py	(revision 3006)
+++ trac/versioncontrol/web_ui/browser.py	(working copy)
@@ -17,6 +17,8 @@
 
 import re
 import urllib
+import os.path
+from fnmatch import fnmatchcase
 
 from trac import util
 from trac.util import sorted
@@ -154,7 +156,10 @@
 
         req.hdf['browser.items'] = info
         req.hdf['browser.changes'] = changes
-        if node.path != '':
+        patterns = self.config.get('browser', 'downloadable_paths')
+        if node.path and patterns and \
+               filter(None, [fnmatchcase(node.path, p) for p in
+                             patterns.split(os.path.pathsep)]):
             zip_href = self.env.href.changeset(rev, node.path, old=rev,
                                                old_path='/', # special case #238
                                                format='zip')

Of course, the most difficult here is to find a sensible configuration setting name and a sensible default:

  • "*": all folders are downloadable
  • "": none are downloadable

Changed 3 years ago by athomas

  • cc athomas added

This would be incredibly useful for TracHacks!

Changed 3 years ago by sid

This feature will probably be used most in root level directories (trunk, branches/0.x-stable, tags/...), not all over the place. In the case where it might be used in a broader fashion (e.g. TrackHacks?), it means there are probably a lot of smaller projects and less overhead to create new archives as needed.

I think the globbing is overkill.

How about:

[browser]
enable_archive_download = true

Changed 3 years ago by cboos

The problem is that there are no fixed rules for identifying what is a root level directory...

E.g. you would like to make each release (/tags/release-x.y.z) downloadable, but certainly not the whole /tags folder, which might contain dozens of releases...

Other example, in Trac hacks, the glob pattern would be /*/*, i.e. anything at the second level, like /authformplugin/0.9 but not /authformplugin itself.

IMHO, a global yes/no flag is useless... Sure you may want to disable the feature completely, but when you want to have it, you want to have some reasonable control over it, as examplified above.

With the glob patterns, complete disabling is very easy, simply leave the option empty, and if control is needed, I can't think of a better compromise between simplicity and flexibility than a list of glob patterns...

Changed 2 years ago by athomas

I agree, globs seem like an excellent choice. I certainly wouldn't want people downloading the entire TracHacks repository.

Changed 2 years ago by cboos

  • status changed from assigned to closed
  • resolution set to fixed

Implemented in r3117.

Changed 2 years ago by cboos

  • keywords objectstore added; helpwanted removed

Note that in the future, it might be worth to use a cache for the zip files, as they can be costly to create.

Changed 2 years ago by athomas

I've updated to trunk on TracHacks and this is working beautifully, thanks Christian :)

A cache would also be quite useful.

Changed 3 weeks ago by stepan@…

Is it possible in a similar way to create "real" tar balls (not .zip files) instead?

Add/Change #238 (Support for downloading tarballs from the repository)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.