mirror of
https://github.com/zoriya/flood.git
synced 2026-06-01 10:35:59 +00:00
server: qBittorrent: set tags after removing all existing tags
APIs of qBittorrent (removeTags, addTags) are incremental. However, currently it is being used to "set" tags. As a result, tags are never removed. This change removes all existing tags before adding new set of tags in order to simulate the idempotent set function.
This commit is contained in:
committed by
Jesse Chan
parent
f1b6d31a1e
commit
a5de58593b
@@ -179,9 +179,11 @@ class QBittorrentClientGatewayService extends ClientGatewayService {
|
||||
}
|
||||
|
||||
async setTorrentsTags({hashes, tags}: SetTorrentsTagsOptions): Promise<void> {
|
||||
return this.clientRequestManager
|
||||
.torrentsAddTags(hashes, tags)
|
||||
.then(this.processClientRequestSuccess, this.processClientRequestError);
|
||||
return this.clientRequestManager.torrentsRemoveTags(hashes).then(() => {
|
||||
this.clientRequestManager
|
||||
.torrentsAddTags(hashes, tags)
|
||||
.then(this.processClientRequestSuccess, this.processClientRequestError);
|
||||
});
|
||||
}
|
||||
|
||||
async setTorrentsTrackers({hashes, trackers}: SetTorrentsTrackersOptions): Promise<void> {
|
||||
|
||||
@@ -253,6 +253,20 @@ class ClientRequestManager {
|
||||
});
|
||||
}
|
||||
|
||||
async torrentsRemoveTags(hashes: Array<string>, tags?: Array<string>): Promise<void> {
|
||||
return axios
|
||||
.get(`${this.apiBase}/torrents/removeTags`, {
|
||||
params: {
|
||||
hashes: hashes.join('|'),
|
||||
tags: tags?.join(','),
|
||||
},
|
||||
headers: {Cookie: await this.authCookie},
|
||||
})
|
||||
.then(() => {
|
||||
// returns nothing
|
||||
});
|
||||
}
|
||||
|
||||
async torrentsAddTrackers(hash: string, urls: Array<string>): Promise<void> {
|
||||
return axios
|
||||
.get(`${this.apiBase}/torrents/addTrackers?hash=${hash}&urls=${urls.join('|')}`, {
|
||||
|
||||
Reference in New Issue
Block a user