mirror of
https://github.com/zoriya/flood.git
synced 2026-05-31 10:22:44 +00:00
API: rename /file-priority API
This commit is contained in:
@@ -242,11 +242,10 @@ const TorrentActions = {
|
||||
},
|
||||
),
|
||||
|
||||
setFilePriority: (hash: TorrentProperties['hash'], fileIndices: Array<number>, priority: number) =>
|
||||
setFilePriority: (hash: TorrentProperties['hash'], indices: Array<number>, priority: number) =>
|
||||
axios
|
||||
.patch(`${baseURI}api/torrents/${hash}/file-priority`, {
|
||||
hash,
|
||||
fileIndices,
|
||||
.patch(`${baseURI}api/torrents/${hash}/contents`, {
|
||||
indices,
|
||||
priority,
|
||||
})
|
||||
.then((json) => json.data)
|
||||
@@ -257,7 +256,7 @@ const TorrentActions = {
|
||||
data: {
|
||||
...data,
|
||||
hash,
|
||||
fileIndices,
|
||||
indices,
|
||||
priority,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -227,12 +227,12 @@ class ClientRequest {
|
||||
}
|
||||
|
||||
setFilePriority(options) {
|
||||
const fileIndices = getEnsuredArray(options.fileIndices);
|
||||
const indices = getEnsuredArray(options.indices);
|
||||
const hashes = getEnsuredArray(options.hashes);
|
||||
|
||||
hashes.forEach((hash) => {
|
||||
fileIndices.forEach((fileIndex) => {
|
||||
this.requests.push(getMethodCall('f.priority.set', [`${hash}:f${fileIndex}`, options.priority]));
|
||||
indices.forEach((index) => {
|
||||
this.requests.push(getMethodCall('f.priority.set', [`${hash}:f${index}`, options.priority]));
|
||||
});
|
||||
this.requests.push(getMethodCall('d.update_priorities', [hash]));
|
||||
});
|
||||
|
||||
@@ -218,11 +218,10 @@ const client = {
|
||||
},
|
||||
|
||||
setFilePriority(user, services, hashes, data, callback) {
|
||||
// TODO Add support for multiple hashes.
|
||||
const {fileIndices} = data;
|
||||
const {indices, priority} = data;
|
||||
const request = new ClientRequest(user, services);
|
||||
|
||||
request.setFilePriority({hashes, fileIndices, priority: data.priority});
|
||||
request.setFilePriority({hashes, indices, priority});
|
||||
request.onComplete((response, error) => {
|
||||
services.torrentService.fetchTorrentList();
|
||||
callback(response, error);
|
||||
|
||||
@@ -211,6 +211,17 @@ router.patch('/tracker', (req, res) => {
|
||||
* @param {string} hash.path
|
||||
*/
|
||||
|
||||
/**
|
||||
* PATCH /api/torrents/{hash}/contents
|
||||
* @summary Sets properties of contents of a torrent. Only priority can be set.
|
||||
* @tags Torrent
|
||||
* @security AuthenticatedUser
|
||||
* @param {string} hash.path
|
||||
*/
|
||||
router.patch('/:hash/contents', (req, res) => {
|
||||
client.setFilePriority(req.user, req.services, req.params.hash, req.body, ajaxUtil.getResponseFn(res));
|
||||
});
|
||||
|
||||
/**
|
||||
* GET /api/torrents/{hash}/contents/{indices}/data
|
||||
* @summary Gets downloaded data of contents of a torrent.
|
||||
@@ -258,15 +269,4 @@ router.patch('/:hash/priority', (req, res) => {
|
||||
client.setPriority(req.user, req.services, req.params.hash, req.body, ajaxUtil.getResponseFn(res));
|
||||
});
|
||||
|
||||
/**
|
||||
* PATCH /api/torrents/{hash}/file-priority
|
||||
* @summary Sets priority of files of a torrent.
|
||||
* @tags Torrent
|
||||
* @security AuthenticatedUser
|
||||
* @param {string} hash.path
|
||||
*/
|
||||
router.patch('/:hash/file-priority', (req, res) => {
|
||||
client.setFilePriority(req.user, req.services, req.params.hash, req.body, ajaxUtil.getResponseFn(res));
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user