mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Give appropriately scary name to dangerous function
"isPathWritable" didn't convey really well the meaning of "let's try to open it, wipe everything the hell out, and see if it worked"
This commit is contained in:
parent
8786f9525e
commit
542cae85d3
|
@ -118,7 +118,7 @@ void FileTransferWidget::autoAcceptTransfer(const QString &path)
|
|||
|
||||
//Do not automatically accept the file-transfer if the path is not writable.
|
||||
//The user can still accept it manually.
|
||||
if (Nexus::isFilePathWritable(filepath))
|
||||
if (Nexus::tryRemoveFile(filepath))
|
||||
Core::getInstance()->acceptFileRecvRequest(fileInfo.friendId, fileInfo.fileNum, filepath);
|
||||
else
|
||||
qDebug() << "Warning: Cannot write to " << filepath;
|
||||
|
@ -130,7 +130,7 @@ void FileTransferWidget::acceptTransfer(const QString &filepath)
|
|||
return;
|
||||
|
||||
//test if writable
|
||||
if(!Nexus::isFilePathWritable(filepath))
|
||||
if(!Nexus::tryRemoveFile(filepath))
|
||||
{
|
||||
QMessageBox::warning(0,
|
||||
tr("Location not writable","Title of permissions popup"),
|
||||
|
|
|
@ -180,7 +180,7 @@ QString Nexus::getSupportedImageFilter()
|
|||
return tr("Images (%1)", "filetype filter").arg(res.left(res.size()-1));
|
||||
}
|
||||
|
||||
bool Nexus::isFilePathWritable(const QString& filepath)
|
||||
bool Nexus::tryRemoveFile(const QString& filepath)
|
||||
{
|
||||
QFile tmp(filepath);
|
||||
bool writable = tmp.open(QIODevice::WriteOnly);
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
static AndroidGUI* getAndroidGUI(); ///< Will return 0 if not started
|
||||
static Widget* getDesktopGUI(); ///< Will return 0 if not started
|
||||
static QString getSupportedImageFilter();
|
||||
static bool isFilePathWritable(const QString& filepath); // WARNING: Tests by brute force, i.e. removes the file in question
|
||||
static bool tryRemoveFile(const QString& filepath); ///< Dangerous way to find out if a path is writable
|
||||
|
||||
private:
|
||||
explicit Nexus(QObject *parent = 0);
|
||||
|
|
|
@ -278,7 +278,7 @@ void ProfileForm::onExportClicked()
|
|||
tr("Tox save file (*.tox)", "save dialog filter"));
|
||||
if (!path.isEmpty())
|
||||
{
|
||||
if (!Nexus::isFilePathWritable(path))
|
||||
if (!Nexus::tryRemoveFile(path))
|
||||
{
|
||||
GUI::showWarning(tr("Location not writable","Title of permissions popup"), tr("You do not have permission to write that location. Choose another, or cancel the save dialog.", "text of permissions popup"));
|
||||
return;
|
||||
|
@ -386,7 +386,7 @@ void ProfileForm::on_saveQr_clicked()
|
|||
tr("Save QrCode (*.png)", "save dialog filter"));
|
||||
if (!path.isEmpty())
|
||||
{
|
||||
if (!Nexus::isFilePathWritable(path))
|
||||
if (!Nexus::tryRemoveFile(path))
|
||||
{
|
||||
GUI::showWarning(tr("Location not writable","Title of permissions popup"), tr("You do not have permission to write that location. Choose another, or cancel the save dialog.", "text of permissions popup"));
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue
Block a user