예제 #1
0
        private async Task Queue(PackageMessage message)
        {
            var         task           = new QueuePackageTask();
            PackageName newPackageName = null;

            // ReSharper disable RedundantArgumentName
            await ProcessPackage(
                message.UserInfo, message.FeedName, message.PackageName,
                PackageState.New, PackageState.DamagedNew,
                tryWithPackageItemBefore : async pi =>
            {
                Trace.TraceInformation("Reading package {0}", pi);
                return(pi);
            },
                tryWithPackage : async(pi, p) =>
            {
                newPackageName = await task.ReadName(message.UserInfo, p);
                await notifier.Starting(message.UserInfo, newPackageName);
            },
                tryWithPackageItemAfter : async pi =>
            {
                Trace.TraceInformation("Queueing package {0} as {1}", pi, newPackageName);

                if (await pi.Copy(PackageState.Original, newPackageName) == null)
                {
                    throw new Exception(string.Format("Failed to copy package {0} to {1}", pi, newPackageName));
                }

                if (await pi.Move(PackageState.IndexingQueued, newPackageName) == null)
                {
                    throw new Exception(string.Format("Failed to move package {0} to {1}", pi, newPackageName));
                }

                message.PackageState = PackageState.IndexingQueued;
                message.PackageName  = newPackageName;
                await scheduler.Signal(message);

                Trace.TraceInformation("Finished queueing package {0} as {1}", pi, newPackageName);
            });

            // ReSharper restore RedundantArgumentName
        }