summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--ui-snapshot.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/ui-snapshot.c b/ui-snapshot.c
index f623f35..84bf8f7 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -39,49 +39,50 @@ static int write_compressed_tar_archive(struct archiver_args *args,const char *f
39 chk_zero(close(rw[1]), "Closing write end of pipe in parent"); 39 chk_zero(close(rw[1]), "Closing write end of pipe in parent");
40 chk_positive(waitpid(gzpid,&status,0), "Waiting on compressor process"); 40 chk_positive(waitpid(gzpid,&status,0), "Waiting on compressor process");
41 if(! ( WIFEXITED(status) && WEXITSTATUS(status)==0 ) ) 41 if(! ( WIFEXITED(status) && WEXITSTATUS(status)==0 ) )
42 cgit_print_error("Failed to compress archive"); 42 cgit_print_error("Failed to compress archive");
43 43
44 return rv; 44 return rv;
45} 45}
46 46
47static int write_tar_gzip_archive(struct archiver_args *args) 47static int write_tar_gzip_archive(struct archiver_args *args)
48{ 48{
49 return write_compressed_tar_archive(args,"gzip"); 49 return write_compressed_tar_archive(args,"gzip");
50} 50}
51static int write_tar_bzip2_archive(struct archiver_args *args) 51static int write_tar_bzip2_archive(struct archiver_args *args)
52{ 52{
53 return write_compressed_tar_archive(args,"bzip2"); 53 return write_compressed_tar_archive(args,"bzip2");
54} 54}
55 55
56static const struct snapshot_archive_t { 56static const struct snapshot_archive_t {
57 const char *suffix; 57 const char *suffix;
58 const char *mimetype; 58 const char *mimetype;
59 write_archive_fn_t write_func; 59 write_archive_fn_t write_func;
60 }snapshot_archives[] = { 60 }snapshot_archives[] = {
61 { ".zip", "application/x-zip", write_zip_archive }, 61 { ".zip", "application/x-zip", write_zip_archive },
62 { ".tar.gz", "application/x-tar", write_tar_gzip_archive }, 62 { ".tar.gz", "application/x-tar", write_tar_gzip_archive },
63 { ".tar.bz2", "application/x-tar", write_tar_bzip2_archive } 63 { ".tar.bz2", "application/x-tar", write_tar_bzip2_archive },
64 { ".tar", "application/x-tar", write_tar_archive }
64}; 65};
65 66
66void cgit_print_snapshot(struct cacheitem *item, const char *hex, 67void cgit_print_snapshot(struct cacheitem *item, const char *hex,
67 const char *prefix, const char *filename) 68 const char *prefix, const char *filename)
68{ 69{
69 int fnl = strlen(filename); 70 int fnl = strlen(filename);
70 int f; 71 int f;
71 for(f=0;f<(sizeof(snapshot_archives)/sizeof(*snapshot_archives));++f) { 72 for(f=0;f<(sizeof(snapshot_archives)/sizeof(*snapshot_archives));++f) {
72 const struct snapshot_archive_t* sat = &snapshot_archives[f]; 73 const struct snapshot_archive_t* sat = &snapshot_archives[f];
73 int sl = strlen(sat->suffix); 74 int sl = strlen(sat->suffix);
74 if(fnl<sl || strcmp(&filename[fnl-sl],sat->suffix)) 75 if(fnl<sl || strcmp(&filename[fnl-sl],sat->suffix))
75 continue; 76 continue;
76 77
77 struct archiver_args args; 78 struct archiver_args args;
78 struct commit *commit; 79 struct commit *commit;
79 unsigned char sha1[20]; 80 unsigned char sha1[20];
80 81
81 if(get_sha1(hex, sha1)) { 82 if(get_sha1(hex, sha1)) {
82 cgit_print_error(fmt("Bad object id: %s", hex)); 83 cgit_print_error(fmt("Bad object id: %s", hex));
83 return; 84 return;
84 } 85 }
85 commit = lookup_commit_reference(sha1); 86 commit = lookup_commit_reference(sha1);
86 87
87 if(!commit) { 88 if(!commit) {