Skip to content

Commit add7ea4

Browse files
committed
skip download if exists
1 parent 74e5c4e commit add7ea4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

internal/actions/actions.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,12 @@ func GetTorrentStatus(g *gocui.Gui, v *gocui.View) error {
119119
func DownloadFile(torrent models.TorrentFileDetailed) error {
120120
path := filepath.Join(config.DownloadPath(), torrent.Filename)
121121

122-
if _, err := os.Stat(path); err == nil {
123-
logs.LogEvent(fmt.Errorf("file already exists, skipping: %s", path))
124-
return err
122+
if fileInfo, err := os.Stat(path); err == nil {
123+
fileSize := fileInfo.Size()
124+
if fileSize >= torrent.Filesize {
125+
logs.LogEvent(fmt.Errorf("file already exists, skipping: %s", path))
126+
return err
127+
}
125128
}
126129
// TODO
127130
// this request does not require authorization

0 commit comments

Comments
 (0)