-rw-r--r-- | ui-snapshot.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ui-snapshot.c b/ui-snapshot.c index 67dbbdd..4449803 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c | |||
@@ -72,65 +72,67 @@ static const struct snapshot_archive_t { | |||
72 | void cgit_print_snapshot(struct cacheitem *item, const char *head, | 72 | void cgit_print_snapshot(struct cacheitem *item, const char *head, |
73 | const char *hex, const char *prefix, | 73 | const char *hex, const char *prefix, |
74 | const char *filename, int snapshots) | 74 | const char *filename, int snapshots) |
75 | { | 75 | { |
76 | const struct snapshot_archive_t* sat; | 76 | const struct snapshot_archive_t* sat; |
77 | struct archiver_args args; | 77 | struct archiver_args args; |
78 | struct commit *commit; | 78 | struct commit *commit; |
79 | unsigned char sha1[20]; | 79 | unsigned char sha1[20]; |
80 | int f, sl, fnl = strlen(filename); | 80 | int f, sl, fnl = strlen(filename); |
81 | 81 | ||
82 | for(f=0; f<snapshot_archives_len; f++) { | 82 | for(f=0; f<snapshot_archives_len; f++) { |
83 | sat = &snapshot_archives[f]; | 83 | sat = &snapshot_archives[f]; |
84 | if(!(snapshots & sat->bit)) | 84 | if(!(snapshots & sat->bit)) |
85 | continue; | 85 | continue; |
86 | sl = strlen(sat->suffix); | 86 | sl = strlen(sat->suffix); |
87 | if(fnl<sl || strcmp(&filename[fnl-sl],sat->suffix)) | 87 | if(fnl<sl || strcmp(&filename[fnl-sl],sat->suffix)) |
88 | continue; | 88 | continue; |
89 | if (!hex) | 89 | if (!hex) |
90 | hex = head; | 90 | hex = head; |
91 | if(get_sha1(hex, sha1)) { | 91 | if(get_sha1(hex, sha1)) { |
92 | cgit_print_error(fmt("Bad object id: %s", hex)); | 92 | cgit_print_error(fmt("Bad object id: %s", hex)); |
93 | return; | 93 | return; |
94 | } | 94 | } |
95 | commit = lookup_commit_reference(sha1); | 95 | commit = lookup_commit_reference(sha1); |
96 | if(!commit) { | 96 | if(!commit) { |
97 | cgit_print_error(fmt("Not a commit reference: %s", hex)); | 97 | cgit_print_error(fmt("Not a commit reference: %s", hex)); |
98 | return;; | 98 | return;; |
99 | } | 99 | } |
100 | memset(&args,0,sizeof(args)); | 100 | memset(&args,0,sizeof(args)); |
101 | args.base = fmt("%s/", prefix); | 101 | args.base = fmt("%s/", prefix); |
102 | args.tree = commit->tree; | 102 | args.tree = commit->tree; |
103 | args.time = commit->date; | 103 | args.time = commit->date; |
104 | cgit_print_snapshot_start(sat->mimetype, filename, item); | 104 | ctx.page.mimetype = xstrdup(sat->mimetype); |
105 | ctx.page.filename = xstrdup(filename); | ||
106 | cgit_print_http_headers(&ctx); | ||
105 | (*sat->write_func)(&args); | 107 | (*sat->write_func)(&args); |
106 | return; | 108 | return; |
107 | } | 109 | } |
108 | cgit_print_error(fmt("Unsupported snapshot format: %s", filename)); | 110 | cgit_print_error(fmt("Unsupported snapshot format: %s", filename)); |
109 | } | 111 | } |
110 | 112 | ||
111 | void cgit_print_snapshot_links(const char *repo, const char *head, | 113 | void cgit_print_snapshot_links(const char *repo, const char *head, |
112 | const char *hex, int snapshots) | 114 | const char *hex, int snapshots) |
113 | { | 115 | { |
114 | const struct snapshot_archive_t* sat; | 116 | const struct snapshot_archive_t* sat; |
115 | char *filename; | 117 | char *filename; |
116 | int f; | 118 | int f; |
117 | 119 | ||
118 | for(f=0; f<snapshot_archives_len; f++) { | 120 | for(f=0; f<snapshot_archives_len; f++) { |
119 | sat = &snapshot_archives[f]; | 121 | sat = &snapshot_archives[f]; |
120 | if(!(snapshots & sat->bit)) | 122 | if(!(snapshots & sat->bit)) |
121 | continue; | 123 | continue; |
122 | filename = fmt("%s-%s%s", cgit_repobasename(repo), hex, | 124 | filename = fmt("%s-%s%s", cgit_repobasename(repo), hex, |
123 | sat->suffix); | 125 | sat->suffix); |
124 | cgit_snapshot_link(filename, NULL, NULL, (char *)head, | 126 | cgit_snapshot_link(filename, NULL, NULL, (char *)head, |
125 | (char *)hex, filename); | 127 | (char *)hex, filename); |
126 | html("<br/>"); | 128 | html("<br/>"); |
127 | } | 129 | } |
128 | } | 130 | } |
129 | 131 | ||
130 | int cgit_parse_snapshots_mask(const char *str) | 132 | int cgit_parse_snapshots_mask(const char *str) |
131 | { | 133 | { |
132 | const struct snapshot_archive_t* sat; | 134 | const struct snapshot_archive_t* sat; |
133 | static const char *delim = " \t,:/|;"; | 135 | static const char *delim = " \t,:/|;"; |
134 | int f, tl, sl, rv = 0; | 136 | int f, tl, sl, rv = 0; |
135 | 137 | ||
136 | /* favor legacy setting */ | 138 | /* favor legacy setting */ |