mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-24 13:34:27 +00:00
Merge pull request #9069 from AltruisticCompany/mkpath
Create non-existing path in setLocationAction()
This commit is contained in:
commit
383a354700
@ -737,9 +737,16 @@ void TorrentsController::setLocationAction()
|
|||||||
const QStringList hashes {params()["hashes"].split("|")};
|
const QStringList hashes {params()["hashes"].split("|")};
|
||||||
const QString newLocation {params()["location"].trimmed()};
|
const QString newLocation {params()["location"].trimmed()};
|
||||||
|
|
||||||
// check if the location exists
|
if (newLocation.isEmpty())
|
||||||
if (newLocation.isEmpty() || !QDir(newLocation).exists())
|
throw APIError(APIErrorType::BadParams, tr("Save path is empty"));
|
||||||
return;
|
|
||||||
|
// try to create the location if it does not exist
|
||||||
|
if (!QDir(newLocation).mkpath("."))
|
||||||
|
throw APIError(APIErrorType::Conflict, tr("Cannot make save path"));
|
||||||
|
|
||||||
|
// check permissions
|
||||||
|
if (!QFileInfo(newLocation).isWritable())
|
||||||
|
throw APIError(APIErrorType::AccessDenied, tr("Cannot write to directory"));
|
||||||
|
|
||||||
applyToTorrents(hashes, [newLocation](BitTorrent::TorrentHandle *torrent)
|
applyToTorrents(hashes, [newLocation](BitTorrent::TorrentHandle *torrent)
|
||||||
{
|
{
|
||||||
|
@ -417,7 +417,7 @@ initializeWindows = function() {
|
|||||||
paddingVertical: 0,
|
paddingVertical: 0,
|
||||||
paddingHorizontal: 0,
|
paddingHorizontal: 0,
|
||||||
width: 400,
|
width: 400,
|
||||||
height: 100
|
height: 130
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -31,8 +31,10 @@
|
|||||||
new Event(e).stop();
|
new Event(e).stop();
|
||||||
// check field
|
// check field
|
||||||
var location = $('setLocation').value.trim();
|
var location = $('setLocation').value.trim();
|
||||||
if (location === null || location === "")
|
if (location === null || location === "") {
|
||||||
|
$('error_div').set('text', 'QBT_TR(Save path is empty)QBT_TR[CONTEXT=TorrentsController]');
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var hashesList = new URI().getData('hashes');
|
var hashesList = new URI().getData('hashes');
|
||||||
new Request({
|
new Request({
|
||||||
@ -42,8 +44,11 @@
|
|||||||
hashes: hashesList,
|
hashes: hashesList,
|
||||||
location: location
|
location: location
|
||||||
},
|
},
|
||||||
onComplete: function() {
|
onSuccess: function() {
|
||||||
window.parent.closeWindows();
|
window.parent.closeWindows();
|
||||||
|
},
|
||||||
|
onFailure: function(xhr) {
|
||||||
|
$('error_div').set('text', xhr.response);
|
||||||
}
|
}
|
||||||
}).send();
|
}).send();
|
||||||
});
|
});
|
||||||
@ -55,6 +60,7 @@
|
|||||||
<div style="padding: 10px 10px 0px 10px;">
|
<div style="padding: 10px 10px 0px 10px;">
|
||||||
<p style="font-weight: bold;">QBT_TR(Location)QBT_TR[CONTEXT=TransferListWidget]:</p>
|
<p style="font-weight: bold;">QBT_TR(Location)QBT_TR[CONTEXT=TransferListWidget]:</p>
|
||||||
<input type="text" id="setLocation" value="" maxlength="100" style="width: 370px;" />
|
<input type="text" id="setLocation" value="" maxlength="100" style="width: 370px;" />
|
||||||
|
<div style="float: none; width: 370px;" id="error_div"> </div>
|
||||||
<div style="text-align: center; padding-top: 10px;">
|
<div style="text-align: center; padding-top: 10px;">
|
||||||
<input type="button" value="QBT_TR(Save)QBT_TR[CONTEXT=HttpServer]" id="setLocationButton" />
|
<input type="button" value="QBT_TR(Save)QBT_TR[CONTEXT=HttpServer]" id="setLocationButton" />
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user