Restore cleanup
This commit is contained in:
parent
d650725523
commit
a5e201c290
@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
- Fixes and improvements to capturing output info and showing it in the UI
|
- Fixes and improvements to capturing output info and showing it in the UI
|
||||||
- Fixes to handling of queued downloads
|
- Fixes to handling of queued downloads
|
||||||
- Fix portable mode to look in binary directory, not current directory
|
- Fix portable mode to look in binary directory, not current directory
|
||||||
|
- Automatically cleanup download list, removing old entries automatically
|
||||||
|
|
||||||
## [v0.5.5] - 2022-04-09
|
## [v0.5.5] - 2022-04-09
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ func (m *Manager) ManageQueue() {
|
|||||||
|
|
||||||
m.startQueued(m.MaxPerDomain)
|
m.startQueued(m.MaxPerDomain)
|
||||||
m.moveToDest()
|
m.moveToDest()
|
||||||
// m.cleanup()
|
m.cleanup()
|
||||||
m.Lock.Unlock()
|
m.Lock.Unlock()
|
||||||
|
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
@ -167,16 +167,17 @@ func (m *Manager) startQueued(maxRunning int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// cleanup removes old downloads from the list. Hardcoded to remove them one hour
|
// cleanup removes old downloads from the list. Hardcoded to remove them one hour
|
||||||
// completion.
|
// completion. Expects the Manager to be locked.
|
||||||
func (m *Manager) XXXcleanup() {
|
func (m *Manager) cleanup() {
|
||||||
newDLs := []*Download{}
|
newDLs := []*Download{}
|
||||||
for _, dl := range m.Downloads {
|
for _, dl := range m.Downloads {
|
||||||
|
dl.Lock.Lock()
|
||||||
if dl.Finished && time.Since(dl.FinishedTS) > time.Duration(time.Hour) {
|
if dl.Finished && time.Since(dl.FinishedTS) > time.Duration(time.Hour) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else {
|
} else {
|
||||||
newDLs = append(newDLs, dl)
|
newDLs = append(newDLs, dl)
|
||||||
}
|
}
|
||||||
|
dl.Lock.Unlock()
|
||||||
|
|
||||||
}
|
}
|
||||||
m.Downloads = newDLs
|
m.Downloads = newDLs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user