mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-11 15:56:17 -07:00
Stop sync requests after qbt has been shutdown
This commit is contained in:
parent
a9741bb203
commit
e31b553807
2 changed files with 24 additions and 7 deletions
|
@ -34,7 +34,9 @@ window.qBittorrent.Client = (() => {
|
|||
return {
|
||||
closeWindows: closeWindows,
|
||||
genHash: genHash,
|
||||
getSyncMainDataInterval: getSyncMainDataInterval
|
||||
getSyncMainDataInterval: getSyncMainDataInterval,
|
||||
isStopped: isStopped,
|
||||
stop: stop
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -56,6 +58,15 @@ window.qBittorrent.Client = (() => {
|
|||
return customSyncMainDataInterval ? customSyncMainDataInterval : serverSyncMainDataInterval;
|
||||
};
|
||||
|
||||
let stopped = false;
|
||||
const isStopped = () => {
|
||||
return stopped;
|
||||
};
|
||||
|
||||
const stop = () => {
|
||||
stopped = true;
|
||||
};
|
||||
|
||||
return exports();
|
||||
})();
|
||||
Object.freeze(window.qBittorrent.Client);
|
||||
|
@ -654,7 +665,7 @@ window.addEventListener("DOMContentLoaded", function() {
|
|||
};
|
||||
})();
|
||||
|
||||
let syncMainDataTimer;
|
||||
let syncMainDataTimeoutID;
|
||||
let syncRequestInProgress = false;
|
||||
const syncMainData = function() {
|
||||
const url = new URI('api/v2/sync/maindata');
|
||||
|
@ -839,10 +850,15 @@ window.addEventListener("DOMContentLoaded", function() {
|
|||
};
|
||||
|
||||
const syncData = function(delay) {
|
||||
if (!syncRequestInProgress) {
|
||||
clearTimeout(syncMainDataTimer);
|
||||
syncMainDataTimer = syncMainData.delay(delay);
|
||||
}
|
||||
if (syncRequestInProgress)
|
||||
return;
|
||||
|
||||
clearTimeout(syncMainDataTimeoutID);
|
||||
|
||||
if (window.qBittorrent.Client.isStopped())
|
||||
return;
|
||||
|
||||
syncMainDataTimeoutID = syncMainData.delay(delay);
|
||||
};
|
||||
|
||||
const processServerState = function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue