]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-snapshot.c
ui-shared: use the same snapshot logic as ui-refs
[ps-cgit] / ui-snapshot.c
index 237a75f76d71d3e1be29cb98b4e5b6f4fd333060..abf83995011075db6668810a8df3da993fc109d5 100644 (file)
@@ -154,7 +154,7 @@ static const char *get_ref_from_filename(const struct cgit_repo *repo,
        if (get_oid(snapshot.buf, &oid) == 0)
                goto out;
 
        if (get_oid(snapshot.buf, &oid) == 0)
                goto out;
 
-       reponame = cgit_repobasename(repo->url);
+       reponame = cgit_snapshot_prefix(repo);
        if (starts_with(snapshot.buf, reponame)) {
                const char *new_start = snapshot.buf;
                new_start += strlen(reponame);
        if (starts_with(snapshot.buf, reponame)) {
                const char *new_start = snapshot.buf;
                new_start += strlen(reponame);
@@ -194,7 +194,7 @@ void cgit_print_snapshot(const char *head, const char *hex,
        }
 
        f = get_format(filename);
        }
 
        f = get_format(filename);
-       if (!f) {
+       if (!f || !(ctx.repo->snapshots & f->bit)) {
                cgit_print_error_page(400, "Bad request",
                                "Unsupported snapshot format: %s", filename);
                return;
                cgit_print_error_page(400, "Bad request",
                                "Unsupported snapshot format: %s", filename);
                return;
@@ -214,7 +214,7 @@ void cgit_print_snapshot(const char *head, const char *hex,
                hex = head;
 
        if (!prefix)
                hex = head;
 
        if (!prefix)
-               prefix = xstrdup(cgit_repobasename(ctx.repo->url));
+               prefix = xstrdup(cgit_snapshot_prefix(ctx.repo));
 
        make_snapshot(f, hex, prefix, filename);
        free(prefix);
 
        make_snapshot(f, hex, prefix, filename);
        free(prefix);