mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-30 19:40:18 -07:00
Improve error detection when saving files
This commit is contained in:
parent
6a6268c068
commit
81139c0098
5 changed files with 21 additions and 23 deletions
|
@ -67,15 +67,12 @@ QDir AsyncFileStorage::storageDir() const
|
|||
void AsyncFileStorage::store_impl(const QString &fileName, const QByteArray &data)
|
||||
{
|
||||
const QString filePath = m_storageDir.absoluteFilePath(fileName);
|
||||
QSaveFile file(filePath);
|
||||
qDebug() << "AsyncFileStorage: Saving data to" << filePath;
|
||||
if (file.open(QIODevice::WriteOnly))
|
||||
|
||||
QSaveFile file(filePath);
|
||||
if (!file.open(QIODevice::WriteOnly) || (file.write(data) != data.length()) || !file.commit())
|
||||
{
|
||||
file.write(data);
|
||||
if (!file.commit())
|
||||
{
|
||||
qDebug() << "AsyncFileStorage: Failed to save data";
|
||||
emit failed(filePath, file.errorString());
|
||||
}
|
||||
qDebug() << "AsyncFileStorage: Failed to save data";
|
||||
emit failed(filePath, file.errorString());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue