]> git.ipfire.org Git - pbs.git/commitdiff
frontend: Only offer files for download that are downloadable
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 8 Jul 2025 09:15:39 +0000 (09:15 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 8 Jul 2025 09:15:39 +0000 (09:15 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
frontend/src/components/PackageFilelist.vue
frontend/src/utils/files.ts [new file with mode: 0644]

index 934cbcafceb336fcadb0bd23e30851634290df68..6893ec26b4bbdad27342d35852e1d22af157e2e5 100644 (file)
@@ -12,6 +12,7 @@
        import Section from "@/components/Section.vue";
 
        // Utils
+       import { fileIsDownloadable } from "@/utils/files";
        import { formatMode, formatSize } from "@/utils/format";
 
        // Fetch the package
@@ -97,7 +98,7 @@
                                        <!-- Actions -->
                                        <td class="is-narrow">
                                                <div class="buttons are-small">
-                                                       <a class="button is-dark"
+                                                       <a class="button is-dark" v-if="fileIsDownloadable(file)"
                                                                        download :href="`/packages/${pkg.uuid}/download${file.path}`">
                                                                <Icon icon="download" :title="$t('Download')" />
                                                        </a>
diff --git a/frontend/src/utils/files.ts b/frontend/src/utils/files.ts
new file mode 100644 (file)
index 0000000..c90c6fc
--- /dev/null
@@ -0,0 +1,11 @@
+import type { File } from "@/api/packages";
+
+/*
+       Helper functions for files
+*/
+export function fileIsDownloadable(file: File): Boolean {
+       const S_IFMT   = 0o170000;
+       const S_IFREG  = 0o100000;
+
+       return (file.mode & S_IFMT) === S_IFREG;
+}