Ignore already existing file when download is requested, fixes #67

This commit is contained in:
Sebastian J. Wolf 2020-10-18 22:14:48 +02:00
parent dba973b522
commit a95dcc4efc

View file

@ -536,10 +536,14 @@ void TDLibWrapper::copyFileToDownloads(const QString &filePath)
QFileInfo fileInfo(filePath);
if (fileInfo.exists()) {
QString downloadFilePath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + "/" + fileInfo.fileName();
if (QFile::copy(filePath, downloadFilePath)) {
if (QFile::exists(downloadFilePath)) {
emit copyToDownloadsSuccessful(fileInfo.fileName(), downloadFilePath);
} else {
emit copyToDownloadsError(fileInfo.fileName(), downloadFilePath);
if (QFile::copy(filePath, downloadFilePath)) {
emit copyToDownloadsSuccessful(fileInfo.fileName(), downloadFilePath);
} else {
emit copyToDownloadsError(fileInfo.fileName(), downloadFilePath);
}
}
} else {
emit copyToDownloadsError(fileInfo.fileName(), filePath);