Mark files as being downloaded from the web on Windows
This commit is contained in:
parent
3b41d20506
commit
b37909a2c8
6 changed files with 25 additions and 3 deletions
|
|
@ -279,9 +279,10 @@ MxcImageProvider::download(const QString &id,
|
|||
}
|
||||
}
|
||||
image.setText(QStringLiteral("mxc url"), "mxc://" + id);
|
||||
if (image.save(fileInfo.absoluteFilePath(), "png"))
|
||||
if (image.save(fileInfo.absoluteFilePath(), "png")) {
|
||||
utils::markFileAsFromWeb(fileInfo.absoluteFilePath());
|
||||
nhlog::ui()->debug("Wrote: {}", fileInfo.absoluteFilePath().toStdString());
|
||||
else
|
||||
} else
|
||||
nhlog::ui()->debug("Failed to write: {}",
|
||||
fileInfo.absoluteFilePath().toStdString());
|
||||
|
||||
|
|
@ -356,6 +357,7 @@ MxcImageProvider::download(const QString &id,
|
|||
}
|
||||
f.write(tempData.data(), tempData.size());
|
||||
f.close();
|
||||
utils::markFileAsFromWeb(fileInfo.absoluteFilePath());
|
||||
|
||||
if (encryptionInfo) {
|
||||
tempData = mtx::crypto::to_string(
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <QBuffer>
|
||||
#include <QComboBox>
|
||||
#include <QCryptographicHash>
|
||||
#include <QFile>
|
||||
#include <QGuiApplication>
|
||||
#include <QImageReader>
|
||||
#include <QProcessEnvironment>
|
||||
|
|
@ -2230,3 +2231,18 @@ utils::parseMatrixUri(QString uri)
|
|||
.vias = std::move(vias),
|
||||
};
|
||||
}
|
||||
|
||||
void
|
||||
utils::markFileAsFromWeb(const QString &path [[maybe_unused]])
|
||||
{
|
||||
#ifdef Q_OS_WINDOWS
|
||||
QFile file(path + ":Zone.Identifier");
|
||||
if (!file.open(QIODevice::Truncate | QIODevice::WriteOnly)) {
|
||||
nhlog::net()->error("Failed to open alternate stream for {}", path.toStdString());
|
||||
return;
|
||||
}
|
||||
|
||||
file.write("[ZoneTransfer]\nZoneId=3");
|
||||
file.close();
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,4 +215,7 @@ struct MatrixUriParseResult
|
|||
|
||||
std::optional<MatrixUriParseResult>
|
||||
parseMatrixUri(QString uri);
|
||||
|
||||
void
|
||||
markFileAsFromWeb(const QString &file);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
#include <QCommandLineParser>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFontDatabase>
|
||||
#include <QLabel>
|
||||
#include <QLibraryInfo>
|
||||
|
|
|
|||
|
|
@ -1990,6 +1990,7 @@ TimelineModel::saveMedia(const QString &eventId) const
|
|||
|
||||
file.write(QByteArray(temp.data(), (int)temp.size()));
|
||||
file.close();
|
||||
utils::markFileAsFromWeb(filename);
|
||||
|
||||
return;
|
||||
} catch (const std::exception &e) {
|
||||
|
|
|
|||
|
|
@ -369,6 +369,7 @@ TimelineViewManager::saveMedia(QString mxcUrl)
|
|||
|
||||
file.write(QByteArray(data.data(), (int)data.size()));
|
||||
file.close();
|
||||
utils::markFileAsFromWeb(filename);
|
||||
|
||||
return;
|
||||
} catch (const std::exception &e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue