jellyfin-web/dashboard-ui/bower_components/emby-apiclient/sync/mediasync.js

488 lines
17 KiB
JavaScript
Raw Normal View History

2016-12-10 00:16:15 -07:00
define(['localassetmanager'], function (localassetmanager) {
2016-10-01 23:13:04 -07:00
'use strict';
2015-09-09 20:22:52 -07:00
2016-12-10 00:16:15 -07:00
function processDownloadStatus(apiClient, serverInfo, options) {
2015-09-09 20:22:52 -07:00
2016-12-10 00:16:15 -07:00
console.log('[mediasync] Begin processDownloadStatus');
2015-09-09 20:22:52 -07:00
2016-12-10 00:16:15 -07:00
return localassetmanager.getServerItems(serverInfo.Id).then(function (items) {
2015-09-09 20:22:52 -07:00
2016-12-10 00:16:15 -07:00
console.log('[mediasync] Begin processDownloadStatus getServerItems completed');
2015-09-14 05:50:37 -07:00
2016-12-10 00:16:15 -07:00
var progressItems = items.filter(function (item) {
return item.SyncStatus === 'transferring' || item.SyncStatus === 'queued';
});
2015-09-14 05:50:37 -07:00
2016-12-10 00:16:15 -07:00
var p = Promise.resolve();
var cnt = 0;
2015-09-14 05:50:37 -07:00
2016-12-10 00:16:15 -07:00
progressItems.forEach(function (item) {
p = p.then(function () {
return reportTransfer(apiClient, item);
2016-08-06 19:56:32 -07:00
});
2016-12-10 00:16:15 -07:00
cnt++;
2016-08-06 19:56:32 -07:00
});
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
return p.then(function () {
console.log('[mediasync] Exit processDownloadStatus. Items reported: ' + cnt.toString());
return Promise.resolve();
2015-09-14 12:47:03 -07:00
});
2016-12-10 00:16:15 -07:00
});
}
function reportTransfer(apiClient, item) {
return localassetmanager.getItemFileSize(item.LocalPath).then(function (size) {
// The background transfer service on Windows leaves the file empty (size = 0) until it
// has been downloaded completely
if (size > 0) {
return apiClient.reportSyncJobItemTransferred(item.SyncJobItemId).then(function () {
item.SyncStatus = 'synced';
return localassetmanager.addOrUpdateLocalItem(item);
}, function (error) {
console.error("[mediasync] Mediasync error on reportSyncJobItemTransferred", error);
item.SyncStatus = 'error';
return localassetmanager.addOrUpdateLocalItem(item);
});
} else {
return localassetmanager.isDownloadInQueue(item.SyncJobItemId).then(function (result) {
if (result) {
// just wait for completion
return Promise.resolve();
}
2015-09-14 05:50:37 -07:00
2016-12-10 00:16:15 -07:00
console.log("[mediasync] reportTransfer: Size is 0 and download no longer in queue. Deleting item.");
return localassetmanager.removeLocalItem(item).then(function () {
console.log('[mediasync] reportTransfer: Item deleted.');
return Promise.resolve();
}, function (err2) {
console.log('[mediasync] reportTransfer: Failed to delete item.', error);
return Promise.resolve();
});
});
}
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
}, function (error) {
2015-09-14 05:50:37 -07:00
2016-12-10 00:16:15 -07:00
console.error('[mediasync] reportTransfer: error on getItemFileSize. Deleting item.', error);
return localassetmanager.removeLocalItem(item).then(function () {
console.log('[mediasync] reportTransfer: Item deleted.');
return Promise.resolve();
}, function (err2) {
console.log('[mediasync] reportTransfer: Failed to delete item.', error);
return Promise.resolve();
});
});
}
2015-09-14 05:50:37 -07:00
2016-12-10 00:16:15 -07:00
function reportOfflineActions(apiClient, serverInfo) {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
console.log('[mediasync] Begin reportOfflineActions');
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
return localassetmanager.getUserActions(serverInfo.Id).then(function (actions) {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
if (!actions.length) {
console.log('[mediasync] Exit reportOfflineActions (no actions)');
return Promise.resolve();
}
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
return apiClient.reportOfflineActions(actions).then(function () {
2016-08-06 19:56:32 -07:00
2016-12-10 00:16:15 -07:00
return localassetmanager.deleteUserActions(actions).then(function () {
console.log('[mediasync] Exit reportOfflineActions (actions reported and deleted.)');
return Promise.resolve();
});
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
}, function (err) {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
// delete those actions even on failure, because if the error is caused by
// the action data itself, this could otherwise lead to a situation that
// never gets resolved
console.error('[mediasync] error on apiClient.reportOfflineActions: ' + err.toString());
return localassetmanager.deleteUserActions(actions);
});
});
}
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
function syncData(apiClient, serverInfo, syncUserItemAccess) {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
console.log('[mediasync] Begin syncData');
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
return localassetmanager.getServerItems(serverInfo.Id).then(function (items) {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
var completedItems = items.filter(function (item) {
return (item) && ((item.SyncStatus === 'synced') || (item.SyncStatus === 'error'));
});
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
var request = {
TargetId: apiClient.deviceId(),
LocalItemIds: completedItems.map(function (xitem) { return xitem.ItemId; }),
OfflineUserIds: (serverInfo.Users || []).map(function (u) { return u.Id; })
};
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
return apiClient.syncData(request).then(function (result) {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
return afterSyncData(apiClient, serverInfo, syncUserItemAccess, result).then(function () {
return Promise.resolve();
}, function () {
return Promise.resolve();
});
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
});
});
}
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
function afterSyncData(apiClient, serverInfo, enableSyncUserItemAccess, syncDataResult) {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
console.log('[mediasync] Begin afterSyncData');
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
var p = Promise.resolve();
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
if (syncDataResult.ItemIdsToRemove) {
syncDataResult.ItemIdsToRemove.forEach(function (itemId) {
p = p.then(function () {
return removeLocalItem(itemId, serverInfo.Id);
});
});
2015-09-14 12:47:03 -07:00
}
2016-12-10 00:16:15 -07:00
if (enableSyncUserItemAccess) {
p = p.then(function () {
return syncUserItemAccess(syncDataResult, serverInfo.Id);
});
}
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
return p.then(function () {
console.log('[mediasync] Exit afterSyncData');
return Promise.resolve();
});
}
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
function removeLocalItem(itemId, serverId) {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
console.log('[mediasync] Begin removeLocalItem');
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
return localassetmanager.getLocalItem(serverId, itemId).then(function (item) {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
if (item) {
return localassetmanager.removeLocalItem(item);
}
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
return Promise.resolve();
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
});
}
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
function getNewMedia(apiClient, serverInfo, options) {
2015-09-14 05:50:37 -07:00
2016-12-10 00:16:15 -07:00
console.log('[mediasync] Begin getNewMedia');
2015-09-14 05:50:37 -07:00
2016-12-10 00:16:15 -07:00
return apiClient.getReadySyncItems(apiClient.deviceId()).then(function (jobItems) {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
var p = Promise.resolve();
2015-09-14 05:50:37 -07:00
2016-12-10 00:16:15 -07:00
jobItems.forEach(function (jobItem) {
p = p.then(function () {
return getNewItem(jobItem, apiClient, serverInfo, options);
});
});
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
return p.then(function () {
console.log('[mediasync] Exit getNewMedia');
return Promise.resolve();
});
});
}
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
function getNewItem(jobItem, apiClient, serverInfo, options) {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
console.log('[mediasync] Begin getNewItem');
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
var libraryItem = jobItem.Item;
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
return localassetmanager.getLocalItem(serverInfo.Id, libraryItem.Id).then(function (existingItem) {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
console.log('[mediasync] getNewItem.getLocalItem completed');
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
if (existingItem) {
if (existingItem.SyncStatus === 'queued' || existingItem.SyncStatus === 'transferring' || existingItem.SyncStatus === 'synced') {
console.log('[mediasync] getNewItem.getLocalItem found existing item');
return Promise.resolve();
}
2015-09-14 12:47:03 -07:00
}
2016-12-10 00:16:15 -07:00
console.log('[mediasync] getNewItem.getLocalItem no existing item found');
2015-09-22 09:06:27 -07:00
2016-12-10 00:16:15 -07:00
return localassetmanager.createLocalItem(libraryItem, serverInfo, jobItem).then(function (localItem) {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
console.log('[mediasync] getNewItem.createLocalItem completed');
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
localItem.SyncStatus = 'queued';
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
return downloadMedia(apiClient, jobItem, localItem, options).then(function () {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
return getImages(apiClient, jobItem, localItem).then(function () {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
return getSubtitles(apiClient, jobItem, localItem);
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
});
});
});
});
}
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
function downloadMedia(apiClient, jobItem, localItem, options) {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
console.log('[mediasync] Begin downloadMedia');
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
var url = apiClient.getUrl("Sync/JobItems/" + jobItem.SyncJobItemId + "/File", {
api_key: apiClient.accessToken()
});
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
var localPath = localItem.LocalPath;
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
console.log('[mediasync] Downloading media. Url: ' + url + '. Local path: ' + localPath);
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
options = options || {};
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
return localassetmanager.downloadFile(url, localItem).then(function (filename) {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
localItem.SyncStatus = 'transferring';
return localassetmanager.addOrUpdateLocalItem(localItem);
});
}
2016-08-06 19:56:32 -07:00
2016-12-10 00:16:15 -07:00
function getImages(apiClient, jobItem, localItem) {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
console.log('[mediasync] Begin getImages');
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
return getNextImage(0, apiClient, localItem);
}
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
function getNextImage(index, apiClient, localItem) {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
console.log('[mediasync] Begin getNextImage');
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
//if (index >= 4) {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
// deferred.resolve();
// return;
//}
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
// Just for now while media syncing gets worked out
return Promise.resolve();
2015-09-24 10:08:10 -07:00
2016-12-10 00:16:15 -07:00
//var libraryItem = localItem.Item;
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
//var serverId = libraryItem.ServerId;
//var itemId = null;
//var imageTag = null;
//var imageType = "Primary";
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
//switch (index) {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
// case 0:
// itemId = libraryItem.Id;
// imageType = "Primary";
// imageTag = (libraryItem.ImageTags || {})["Primary"];
// break;
// case 1:
// itemId = libraryItem.SeriesId;
// imageType = "Primary";
// imageTag = libraryItem.SeriesPrimaryImageTag;
// break;
// case 2:
// itemId = libraryItem.SeriesId;
// imageType = "Thumb";
// imageTag = libraryItem.SeriesPrimaryImageTag;
// break;
// case 3:
// itemId = libraryItem.AlbumId;
// imageType = "Primary";
// imageTag = libraryItem.AlbumPrimaryImageTag;
// break;
// default:
// break;
//}
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
//if (!itemId || !imageTag) {
// getNextImage(index + 1, apiClient, localItem, deferred);
// return;
//}
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
//downloadImage(apiClient, serverId, itemId, imageTag, imageType).then(function () {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
// // For the sake of simplicity, limit to one image
// deferred.resolve();
// return;
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
// getNextImage(index + 1, apiClient, localItem, deferred);
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
//}, getOnFail(deferred));
}
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
function downloadImage(apiClient, serverId, itemId, imageTag, imageType) {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
console.log('[mediasync] Begin downloadImage');
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
return localassetmanager.hasImage(serverId, itemId, imageTag).then(function (hasImage) {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
if (hasImage) {
return Promise.resolve();
2015-09-14 14:24:54 -07:00
}
2016-12-10 00:16:15 -07:00
var imageUrl = apiClient.getImageUrl(itemId, {
tag: imageTag,
type: imageType,
api_key: apiClient.accessToken()
});
2015-09-14 18:16:31 -07:00
2016-12-10 00:16:15 -07:00
return localassetmanager.downloadImage(imageUrl, serverId, itemId, imageTag);
});
}
2015-09-14 18:16:31 -07:00
2016-12-10 00:16:15 -07:00
function getSubtitles(apiClient, jobItem, localItem) {
2015-09-14 18:16:31 -07:00
2016-12-10 00:16:15 -07:00
console.log('[mediasync] Begin getSubtitles');
2015-09-14 18:16:31 -07:00
2016-12-10 00:16:15 -07:00
if (!jobItem.Item.MediaSources.length) {
console.log("[mediasync] Cannot download subtitles because video has no media source info.");
return Promise.resolve();
}
2015-09-14 18:16:31 -07:00
2016-12-10 00:16:15 -07:00
var files = jobItem.AdditionalFiles.filter(function (f) {
return f.Type === 'Subtitles';
});
2015-09-14 18:16:31 -07:00
2016-12-10 00:16:15 -07:00
var mediaSource = jobItem.Item.MediaSources[0];
2015-09-14 18:16:31 -07:00
2016-12-10 00:16:15 -07:00
var p = Promise.resolve();
2015-09-14 18:16:31 -07:00
2016-12-10 00:16:15 -07:00
files.forEach(function (file) {
p = p.then(function () {
return getItemSubtitle(file, apiClient, jobItem, localItem, mediaSource);
2015-09-14 18:16:31 -07:00
});
2016-12-10 00:16:15 -07:00
});
2015-09-14 18:16:31 -07:00
2016-12-10 00:16:15 -07:00
return p.then(function () {
console.log('[mediasync] Exit getSubtitles');
return Promise.resolve();
});
}
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
function getItemSubtitle(file, apiClient, jobItem, localItem, mediaSource) {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
console.log('[mediasync] Begin getItemSubtitle');
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
var subtitleStream = mediaSource.MediaStreams.filter(function (m) {
return m.Type === 'Subtitle' && m.Index === file.Index;
})[0];
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
if (!subtitleStream) {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
// We shouldn't get in here, but let's just be safe anyway
console.log("[mediasync] Cannot download subtitles because matching stream info wasn't found.");
return Promise.resolve();
2015-09-14 14:24:54 -07:00
}
2016-12-10 00:16:15 -07:00
var url = apiClient.getUrl("Sync/JobItems/" + jobItem.SyncJobItemId + "/AdditionalFiles", {
Name: file.Name,
api_key: apiClient.accessToken()
});
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
var fileName = localassetmanager.getSubtitleSaveFileName(jobItem.OriginalFileName, subtitleStream.Language, subtitleStream.IsForced, subtitleStream.Codec);
var localFilePath = localassetmanager.getLocalFilePath(localItem, fileName);
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
return localassetmanager.downloadSubtitles(url, localFilePath).then(function (subtitlePath) {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
subtitleStream.Path = subtitlePath;
return localassetmanager.addOrUpdateLocalItem(localItem);
});
}
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
return function () {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
var self = this;
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
self.sync = function (apiClient, serverInfo, options) {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
console.log("[mediasync]************************************* Start sync");
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
return processDownloadStatus(apiClient, serverInfo, options).then(function () {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
return reportOfflineActions(apiClient, serverInfo).then(function () {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
//// Do the first data sync
//return syncData(apiClient, serverInfo, false).then(function () {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
// Download new content
return getNewMedia(apiClient, serverInfo, options).then(function () {
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
// Do the second data sync
return syncData(apiClient, serverInfo, false).then(function () {
console.log("[mediasync]************************************* Exit sync");
});
});
//});
});
2015-09-14 14:24:54 -07:00
});
2016-12-10 00:16:15 -07:00
};
};
2015-09-14 14:24:54 -07:00
2016-12-10 00:16:15 -07:00
//function syncUserItemAccess(syncDataResult, serverId) {
// console.log('[mediasync] Begin syncUserItemAccess');
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
// var itemIds = [];
// for (var id in syncDataResult.ItemUserAccess) {
// itemIds.push(id);
// }
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
// return syncNextUserAccessForItem(itemIds, 0, syncDataResult, serverId);
//}
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
//function syncNextUserAccessForItem(itemIds, index, syncDataResult, serverId) {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
// var length = itemIds.length;
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
// if (index >= length) {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
// return Promise.resolve
// return;
// }
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
// syncUserAccessForItem(itemIds[index], syncDataResult).then(function () {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
// syncNextUserAccessForItem(itemIds, index + 1, syncDataResult, serverId, deferred);
// }, function () {
// syncNextUserAccessForItem(itemIds, index + 1, syncDataResult, serverId, deferred);
// });
//}
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
//function syncUserAccessForItem(itemId, syncDataResult) {
// console.log('[mediasync] Begin syncUserAccessForItem');
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
// var deferred = DeferredBuilder.Deferred();
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
// localassetmanager.getUserIdsWithAccess(itemId, serverId).then(function (savedUserIdsWithAccess) {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
// var userIdsWithAccess = syncDataResult.ItemUserAccess[itemId];
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
// if (userIdsWithAccess.join(',') === savedUserIdsWithAccess.join(',')) {
// // Hasn't changed, nothing to do
// deferred.resolve();
// }
// else {
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
// localassetmanager.saveUserIdsWithAccess(itemId, serverId, userIdsWithAccess).then(function () {
// deferred.resolve();
// }, getOnFail(deferred));
// }
2015-09-14 12:47:03 -07:00
2016-12-10 00:16:15 -07:00
// }, getOnFail(deferred));
2015-09-14 05:50:37 -07:00
2016-12-10 00:16:15 -07:00
// return deferred.promise();
//}
2015-09-14 05:50:37 -07:00
2016-12-10 00:16:15 -07:00
//}
2015-09-14 05:50:37 -07:00
2016-08-06 19:56:32 -07:00
});