Skip to content

Commit 4dac465

Browse files
committed
Fix crash after consecutive failed downloads
A segmentation fault was caused by an uninitialized mutex if an IO error occurred on two consecutive downloads. The mutex is now explicitly initialized on all code paths. Also, filled out the rest of the struct just to be safe for the future.
1 parent 17f2faa commit 4dac465

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

data/cache.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,15 @@ func (c *Cache) Download(item *QueueItem) (id int, err error) {
163163

164164
if err != nil {
165165
dl = Download{
166+
mut: new(sync.RWMutex),
167+
Path: item.Path,
168+
File: f,
169+
Elem: item,
166170
Started: time.Now(),
167171
Completed: true,
168172
Success: false,
169-
Elem: item,
170173
Error: "IO Error",
174+
Stop: nil,
171175
}
172176

173177
c.downloadsMutex.Lock()

0 commit comments

Comments
 (0)