mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
Enhance download options and improve git error handling (#100)
* Fix download dialog to show gitignored paths with opt-in selection - Add getIgnoredPathsList API to detect gitignored files from git root - Fix git check-ignore to run from proper git root directory - Add ignored paths checkboxes in download dialog for opt-in inclusion - Support includeGit and includePaths options in download endpoints - Fix dialog button event handling to prevent page reload * Add clone timeout and improve git error handling * Refactor path extraction in download-zip endpoint
This commit is contained in:
1 parent
a02f7a2e98
commit
eccd49e877
12 files changed
+542
-121
No files matched your search
@@ -44,8 +44,28 @@ export async function applyFilePatches(path: string, patches: PatchOperation[]):
|
||||
return response.json()
|
||||
}
|
||||
|
||||
export async function downloadDirectoryAsZip(path: string): Promise<void> {
|
||||
const response = await fetch(`${API_BASE_URL}/api/files/${path}/download-zip`)
|
||||
export async function getIgnoredPaths(path: string): Promise<{ ignoredPaths: string[] }> {
|
||||
const response = await fetch(`${API_BASE_URL}/api/files/${path}/ignored-paths`)
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to get ignored paths')
|
||||
}
|
||||
|
||||
return response.json()
|
||||
}
|
||||
|
||||
export interface DownloadOptions {
|
||||
includeGit?: boolean
|
||||
includePaths?: string[]
|
||||
}
|
||||
|
||||
export async function downloadDirectoryAsZip(path: string, options?: DownloadOptions): Promise<void> {
|
||||
const params = new URLSearchParams()
|
||||
if (options?.includeGit) params.append('includeGit', 'true')
|
||||
if (options?.includePaths?.length) params.append('includePaths', options.includePaths.join(','))
|
||||
|
||||
const url = `${API_BASE_URL}/api/files/${path}/download-zip${params.toString() ? '?' + params.toString() : ''}`
|
||||
const response = await fetch(url)
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json()
|
||||
@@ -53,13 +73,13 @@ export async function downloadDirectoryAsZip(path: string): Promise<void> {
|
||||
}
|
||||
|
||||
const blob = await response.blob()
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const urlObj = window.URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.href = urlObj
|
||||
const dirName = path.split('/').pop() || 'download'
|
||||
a.download = `${dirName}.zip`
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(a)
|
||||
window.URL.revokeObjectURL(url)
|
||||
window.URL.revokeObjectURL(urlObj)
|
||||
}
|
||||
@@ -180,8 +180,18 @@ export async function createBranch(id: number, branch: string): Promise<Repo> {
|
||||
return response.json()
|
||||
}
|
||||
|
||||
export async function downloadRepo(id: number, repoName: string): Promise<void> {
|
||||
const response = await fetch(`${API_BASE_URL}/api/repos/${id}/download`)
|
||||
export interface DownloadOptions {
|
||||
includeGit?: boolean
|
||||
includePaths?: string[]
|
||||
}
|
||||
|
||||
export async function downloadRepo(id: number, repoName: string, options?: DownloadOptions): Promise<void> {
|
||||
const params = new URLSearchParams()
|
||||
if (options?.includeGit) params.append('includeGit', 'true')
|
||||
if (options?.includePaths?.length) params.append('includePaths', options.includePaths.join(','))
|
||||
|
||||
const url = `${API_BASE_URL}/api/repos/${id}/download${params.toString() ? '?' + params.toString() : ''}`
|
||||
const response = await fetch(url)
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json()
|
||||
@@ -189,14 +199,14 @@ export async function downloadRepo(id: number, repoName: string): Promise<void>
|
||||
}
|
||||
|
||||
const blob = await response.blob()
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const urlObj = window.URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.href = urlObj
|
||||
a.download = `${repoName}.zip`
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(a)
|
||||
window.URL.revokeObjectURL(url)
|
||||
window.URL.revokeObjectURL(urlObj)
|
||||
}
|
||||
|
||||
export async function updateRepoOrder(order: number[]): Promise<void> {
|
||||
|
||||
Reference in new issue
Block a user