feat(port): add download directory and event interfaces
- commit
- 51ce92766e3ed64a4cce12a0a80c773acc9ca482
- author
- brice · · 2026-01-07 09:55 UTC
- parent
- f5ba636
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +32 -0
A internal/application/port/download.go +28 -0
| @@ -0,0 +1,28 @@ | |||
| 1 | + | package port | |
| 2 | + | ||
| 3 | + | import "context" | |
| 4 | + | ||
| 5 | + | // DownloadEventType represents the type of download event. | |
| 6 | + | type DownloadEventType int | |
| 7 | + | ||
| 8 | + | const ( | |
| 9 | + | // DownloadEventStarted indicates a download has begun. | |
| 10 | + | DownloadEventStarted DownloadEventType = iota | |
| 11 | + | // DownloadEventFinished indicates a download completed successfully. | |
| 12 | + | DownloadEventFinished | |
| 13 | + | // DownloadEventFailed indicates a download failed. | |
| 14 | + | DownloadEventFailed | |
| 15 | + | ) | |
| 16 | + | ||
| 17 | + | // DownloadEvent contains information about a download event. | |
| 18 | + | type DownloadEvent struct { | |
| 19 | + | Type DownloadEventType | |
| 20 | + | Filename string | |
| 21 | + | Destination string | |
| 22 | + | Error error // Set when Type is DownloadEventFailed | |
| 23 | + | } | |
| 24 | + | ||
| 25 | + | // DownloadEventHandler receives download event notifications. | |
| 26 | + | type DownloadEventHandler interface { | |
| 27 | + | OnDownloadEvent(ctx context.Context, event DownloadEvent) | |
| 28 | + | } | |
| @@ -0,0 +1,28 @@ | |||||
| 1 | + | package port | |||
| 2 | + | ||||
| 3 | + | import "context" | |||
| 4 | + | ||||
| 5 | + | // DownloadEventType represents the type of download event. | |||
| 6 | + | type DownloadEventType int | |||
| 7 | + | ||||
| 8 | + | const ( | |||
| 9 | + | // DownloadEventStarted indicates a download has begun. | |||
| 10 | + | DownloadEventStarted DownloadEventType = iota | |||
| 11 | + | // DownloadEventFinished indicates a download completed successfully. | |||
| 12 | + | DownloadEventFinished | |||
| 13 | + | // DownloadEventFailed indicates a download failed. | |||
| 14 | + | DownloadEventFailed | |||
| 15 | + | ) | |||
| 16 | + | ||||
| 17 | + | // DownloadEvent contains information about a download event. | |||
| 18 | + | type DownloadEvent struct { | |||
| 19 | + | Type DownloadEventType | |||
| 20 | + | Filename string | |||
| 21 | + | Destination string | |||
| 22 | + | Error error // Set when Type is DownloadEventFailed | |||
| 23 | + | } | |||
| 24 | + | ||||
| 25 | + | // DownloadEventHandler receives download event notifications. | |||
| 26 | + | type DownloadEventHandler interface { | |||
| 27 | + | OnDownloadEvent(ctx context.Context, event DownloadEvent) | |||
| 28 | + | } | |||
M internal/application/port/xdg.go +4 -0
| @@ -14,4 +14,8 @@ type XDGPaths interface { | |||
| 14 | 14 | // ManDir returns the user man page directory (man1 section). | |
| 15 | 15 | // Typically $XDG_DATA_HOME/man/man1 or ~/.local/share/man/man1. | |
| 16 | 16 | ManDir() (string, error) | |
| 17 | + | ||
| 18 | + | // DownloadDir returns the user's download directory. | |
| 19 | + | // Typically $XDG_DOWNLOAD_DIR or ~/Downloads. | |
| 20 | + | DownloadDir() (string, error) | |
| 17 | 21 | } | |
| @@ -14,4 +14,8 @@ type XDGPaths interface { | |||||
| 14 | // ManDir returns the user man page directory (man1 section). | 14 | // ManDir returns the user man page directory (man1 section). | ||
| 15 | // Typically $XDG_DATA_HOME/man/man1 or ~/.local/share/man/man1. | 15 | // Typically $XDG_DATA_HOME/man/man1 or ~/.local/share/man/man1. | ||
| 16 | ManDir() (string, error) | 16 | ManDir() (string, error) | ||
| 17 | + | ||||
| 18 | + | // DownloadDir returns the user's download directory. | |||
| 19 | + | // Typically $XDG_DOWNLOAD_DIR or ~/Downloads. | |||
| 20 | + | DownloadDir() (string, error) | |||
| 17 | } | 21 | } | ||