fixed item not switching to "Open/Play" when DL is finished in channel/post/files

This commit is contained in:
csoler 2023-06-30 17:24:55 +02:00
parent bb533eefc8
commit df68d03953

View File

@ -90,7 +90,15 @@ void GxsChannelFilesStatusWidget::setSize(uint64_t size)
void GxsChannelFilesStatusWidget::check() void GxsChannelFilesStatusWidget::check()
{ {
FileInfo fileInfo; FileInfo fileInfo;
if (rsFiles->alreadyHaveFile(mFile.mHash, fileInfo)) {
bool already_has_file = rsFiles->alreadyHaveFile(mFile.mHash, fileInfo);
bool detailsOk = false;
if(!already_has_file)
detailsOk = rsFiles->FileDetails(mFile.mHash, RS_FILE_HINTS_DOWNLOAD | RS_FILE_HINTS_SPEC_ONLY, fileInfo);
if (already_has_file || (detailsOk && fileInfo.downloadStatus == FT_STATE_COMPLETE))
{
mState = STATE_LOCAL; mState = STATE_LOCAL;
setSize(fileInfo.size); setSize(fileInfo.size);
@ -103,27 +111,25 @@ void GxsChannelFilesStatusWidget::check()
ui->openFilePushButton->setText(tr("Play")); ui->openFilePushButton->setText(tr("Play"));
ui->openFilePushButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/play.png")); ui->openFilePushButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/play.png"));
} }
}
} else { else if (detailsOk)
FileInfo fileInfo; {
bool detailsOk = rsFiles->FileDetails(mFile.mHash, RS_FILE_HINTS_DOWNLOAD | RS_FILE_HINTS_SPEC_ONLY, fileInfo); switch (fileInfo.downloadStatus)
{
if (detailsOk) {
switch (fileInfo.downloadStatus) {
case FT_STATE_WAITING: case FT_STATE_WAITING:
mState = STATE_WAITING; mState = STATE_WAITING;
break; break;
case FT_STATE_DOWNLOADING: case FT_STATE_DOWNLOADING:
if (fileInfo.avail == fileInfo.size) { if (fileInfo.avail == fileInfo.size)
mState = STATE_LOCAL; mState = STATE_LOCAL;
} else { else
mState = STATE_DOWNLOAD; mState = STATE_DOWNLOAD;
}
setSize(fileInfo.size); setSize(fileInfo.size);
ui->progressBar->setValue(fileInfo.avail / mDivisor); ui->progressBar->setValue(fileInfo.avail / mDivisor);
break; break;
case FT_STATE_COMPLETE: case FT_STATE_COMPLETE: // this should not happen, since the case is handled earlier
mState = STATE_DOWNLOAD; mState = STATE_ERROR;
break; break;
case FT_STATE_QUEUED: case FT_STATE_QUEUED:
mState = STATE_WAITING; mState = STATE_WAITING;
@ -138,10 +144,9 @@ void GxsChannelFilesStatusWidget::check()
mState = STATE_ERROR; mState = STATE_ERROR;
break; break;
} }
} else { }
else
mState = STATE_REMOTE; mState = STATE_REMOTE;
}
}
int repeat = 0; int repeat = 0;
QString statusText; QString statusText;