moveTorrents: Allow hash check to be skipped by user

Signed-off-by: Jesse Chan <jc@linux.com>
This commit is contained in:
Jesse Chan
2020-08-04 13:12:56 +08:00
parent c7f69407dd
commit 0eae92faf5
4 changed files with 26 additions and 8 deletions
@@ -135,7 +135,7 @@ const TorrentActions = {
),
moveTorrents: (hashes, options) => {
const {destination, isBasePath, filenames, sourcePaths, moveFiles} = options;
const {destination, isBasePath, filenames, sourcePaths, moveFiles, isCheckHash} = options;
return axios
.post(`${baseURI}api/client/torrents/move`, {
@@ -145,6 +145,7 @@ const TorrentActions = {
filenames,
sourcePaths,
moveFiles,
isCheckHash,
})
.then((json = {}) => json.data)
.then(
@@ -31,6 +31,15 @@ class MoveTorrents extends React.Component {
id: 'moveFiles',
type: 'checkbox',
},
{
checked: true,
content: this.props.intl.formatMessage({
id: 'torrents.move.check_hash.label',
defaultMessage: 'Check hash',
}),
id: 'isCheckHash',
type: 'checkbox',
},
{
content: this.props.intl.formatMessage({
id: 'button.cancel',
@@ -74,6 +83,7 @@ class MoveTorrents extends React.Component {
filenames,
moveFiles: formData.moveFiles,
sourcePaths,
isCheckHash: formData.isCheckHash,
}).then(() => {
this.setState({isSettingDownloadPath: false});
});
+1
View File
@@ -311,6 +311,7 @@ export default {
'torrents.move.button.set.location': 'Set Location',
'torrents.move.button.state.setting': 'Setting...',
'torrents.move.data.label': 'Move data',
'torrents.move.check_hash.label': 'Check hash',
'torrents.move.heading': 'Set Torrent Location',
'torrents.properties.date.added': 'Added',
+13 -7
View File
@@ -227,7 +227,7 @@ const client = {
moveTorrents(user, services, data, callback) {
const destinationPath = data.destination;
const {isBasePath, hashes, filenames, moveFiles, sourcePaths} = data;
const {isBasePath, hashes, filenames, moveFiles, sourcePaths, isCheckHash} = data;
const mainRequest = new ClientRequest(user, services);
const hashesToRestart = hashes.filter(
@@ -247,12 +247,18 @@ const client = {
afterCheckHash = callback;
}
const checkHash = () => {
const checkHashRequest = new ClientRequest(user, services);
checkHashRequest.checkHash({hashes});
checkHashRequest.onComplete(afterCheckHash);
checkHashRequest.send();
};
let checkHash;
if (isCheckHash) {
checkHash = () => {
const checkHashRequest = new ClientRequest(user, services);
checkHashRequest.checkHash({hashes});
checkHashRequest.onComplete(afterCheckHash);
checkHashRequest.send();
};
} else {
checkHash = afterCheckHash;
}
const moveTorrents = () => {
const moveTorrentsRequest = new ClientRequest(user, services);