Don't clean up partial downloads, such that they can be resumed

This commit is contained in:
Bart De Vries 2021-06-04 22:59:50 +02:00
parent a24fb7d731
commit 1f35c0a25c
1 changed files with 3 additions and 3 deletions

View File

@ -58,7 +58,7 @@ Enclosure::Enclosure(Entry *entry)
if (file.size() == m_size && file.size() > 0) { if (file.size() == m_size && file.size() > 0) {
if (m_status == Downloadable) { if (m_status == Downloadable) {
// file is on disk, but was not expected, write to database // file is on disk, but was not expected, write to database
// this should never happen // this should, in principle, never happen unless the db was deleted
m_status = Downloaded; m_status = Downloaded;
query.prepare(QStringLiteral("UPDATE Enclosures SET downloaded=:downloaded WHERE id=:id;")); query.prepare(QStringLiteral("UPDATE Enclosures SET downloaded=:downloaded WHERE id=:id;"));
query.bindValue(QStringLiteral(":id"), entry->id()); query.bindValue(QStringLiteral(":id"), entry->id());
@ -68,8 +68,8 @@ Enclosure::Enclosure(Entry *entry)
} else { } else {
if (m_status == Downloaded) { if (m_status == Downloaded) {
// file was downloaded, but there is a size mismatch or file is empty // file was downloaded, but there is a size mismatch or file is empty
// delete file and update status in database // update status in database
file.remove(); // don't actually delete the file such that the download can be resumed
m_status = Downloadable; m_status = Downloadable;
query.prepare(QStringLiteral("UPDATE Enclosures SET downloaded=:downloaded WHERE id=:id;")); query.prepare(QStringLiteral("UPDATE Enclosures SET downloaded=:downloaded WHERE id=:id;"));
query.bindValue(QStringLiteral(":id"), entry->id()); query.bindValue(QStringLiteral(":id"), entry->id());