Пример #1
0
        private async Task UpdateOrAddContentInfo(UploadFolder request, IAbsoluteDirectoryPath path)
        {
            var cl = await ContentLinkContext.GetFolderLink().ConfigureAwait(false);

            var l           = cl.Infos.FirstOrDefault(x => x.Path.Equals(path));
            var contentInfo = new ContentInfo(request.UserId, request.GameId, request.ContentId);

            if (l != null)
            {
                l.ContentInfo = contentInfo;
            }
            else
            {
                cl.Infos.Add(new FolderInfo(path, contentInfo));
            }
        }
Пример #2
0
        public async Task <Guid> Handle(UploadFolder request)
        {
            var path = request.Folder.ToAbsoluteDirectoryPath();

            if (!await _folderHandler.IsFolderWhitelisted(path).ConfigureAwait(false))
            {
                throw new ValidationException("This folder was not yet whitelisted!");
            }

            await UpdateOrAddContentInfo(request, path).ConfigureAwait(false);

            // intermediate save..
            await ContentLinkContext.SaveChanges().ConfigureAwait(false);

            var id = await
                     _queueManager.AddToQueue("Upload " + path.DirectoryName, request.ContentId,
                                              (progress, ct) => UploadAndProgressHandling(request, ct, progress)).ConfigureAwait(false);

            // Not retry compatible atm, also this is more a workaround for the upload stuff
            var item = _queueManager.Queue.Items.First(x => x.Id == id);
            await item.Task.ConfigureAwait(false);

            return(id);
        }
Пример #3
0
 public async Task <List <FolderInfo> > Handle(GetFolders request)
 =>
 (await ContentLinkContext.GetFolderLink().ConfigureAwait(false)).Infos.Where(
     x => request.Folders.Contains(x.Path.ToString())).ToList();
Пример #4
0
 public async Task <IAbsoluteDirectoryPath> Handle(GetUploadFolder request)
 =>
 (await ContentLinkContext.GetFolderLink().ConfigureAwait(false)).Infos.FirstOrDefault(
     x => x.ContentInfo.ContentId == request.ContentId)?
 .Path;