Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/components/FilesystemInspector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,7 @@ const comparisonModeColumns = computed<DataTableColumns<FilesystemDiffEntry>>(()
const handleDownload = async (hash: string, commitName: string) => {
downloadingHash.value = hash
try {
const filename = getDownloadFilename(row.name, commitName, hash)
await downloadBlob(hash, filename)
await downloadBlob(hash, row.name, getDownloadFilename(row.name, commitName, hash))
} catch (error) {
console.error('Download failed:', error)
alert(error instanceof Error ? error.message : 'Download failed')
Expand Down
13 changes: 11 additions & 2 deletions src/utils/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,23 @@ export function generateBreadcrumbs(path: string, includeHome = true): Breadcrum

/**
* Download a blob by hash.
*
* `filename` is the real PE basename sent as `?filename=` so the API can resolve
* the blob on Winbindex. `saveAs` is the (possibly decorated) name shown to the
* user; it defaults to `filename` and never reaches the server.
*/
export async function downloadBlob(hash: string, filename: string): Promise<void> {
export async function downloadBlob(
hash: string,
filename: string,
saveAs: string = filename
): Promise<void> {
const apiUri = import.meta.env.VITE_OSWATCHER_API_URI
if (!apiUri) {
throw new Error('VITE_OSWATCHER_API_URI not configured')
}

const url = new URL(`/blob/${hash}`, apiUri)
url.searchParams.set('filename', filename)

const response = await fetch(url.toString())

Expand All @@ -114,7 +123,7 @@ export async function downloadBlob(hash: string, filename: string): Promise<void

const a = document.createElement('a')
a.href = downloadUrl
a.download = filename
a.download = saveAs
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
Expand Down
Loading