mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-18 11:28:23 -07:00
58 lines
1.4 KiB
JavaScript
58 lines
1.4 KiB
JavaScript
|
(function (globalScope) {
|
|||
|
|
|||
|
function multiServerSync(connectionManager) {
|
|||
|
|
|||
|
self.sync = function () {
|
|||
|
|
|||
|
var deferred = DeferredBuilder.Deferred();
|
|||
|
|
|||
|
connectionManager.getAvailableServers().done(function (result) {
|
|||
|
syncNext(result, 0, deferred);
|
|||
|
});
|
|||
|
|
|||
|
return deferred.promise();
|
|||
|
};
|
|||
|
|
|||
|
function syncNext(servers, index, deferred) {
|
|||
|
|
|||
|
var length = servers.length;
|
|||
|
|
|||
|
if (index >= length) {
|
|||
|
|
|||
|
deferred.resolve();
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (progress.isCancelled) {
|
|||
|
deferred.reject();
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
var server = servers[index];
|
|||
|
|
|||
|
// get fresh info from connection manager
|
|||
|
server = connectionManager.getServerInfo(server.Id) || server;
|
|||
|
|
|||
|
Logger.log("Creating ServerSync to server: " + server.Id);
|
|||
|
|
|||
|
require(['serversync'], function () {
|
|||
|
|
|||
|
new MediaBrowser.ServerSync(connectionManager).sync(server).done(function () {
|
|||
|
|
|||
|
syncNext(servers, index + 1, deferred);
|
|||
|
|
|||
|
}).fail(function () {
|
|||
|
|
|||
|
syncNext(servers, index + 1, deferred);
|
|||
|
});
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (!globalScope.MediaBrowser) {
|
|||
|
globalScope.MediaBrowser = {};
|
|||
|
}
|
|||
|
|
|||
|
globalScope.MediaBrowser.MultiServerSync = multiServerSync;
|
|||
|
|
|||
|
})(this);
|