Skip to content

Commit d7d3229

Browse files
committed
another fix
Signed-off-by: abzcoding <[email protected]>
1 parent d567dac commit d7d3229

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

main.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,21 @@ func Execute(url string, state *State, conn int, skiptls bool, proxy string, bwL
170170
Warnf("Interrupted, but the download is not resumable. Exiting silently.\n")
171171
}
172172
} else {
173+
// Rebuild files from folder to avoid any missing/duplicate paths from channels
174+
folder := FolderOf(url)
175+
entries, readErr := os.ReadDir(folder)
176+
FatalCheck(readErr)
177+
files = files[:0]
178+
prefix := TaskFromURL(url) + ".part"
179+
for _, e := range entries {
180+
if e.IsDir() {
181+
continue
182+
}
183+
name := e.Name()
184+
if strings.HasPrefix(name, prefix) {
185+
files = append(files, folder+string(os.PathSeparator)+name)
186+
}
187+
}
173188
err := JoinFile(files, TaskFromURL(url))
174189
FatalCheck(err)
175190
err = os.RemoveAll(FolderOf(url))

0 commit comments

Comments
 (0)