Exemplo n.º 1
0
        private IEnumerable <Task <SynchronizationReport> > SynchronizePendingFilesAsync(SynchronizationClient destination, bool forceSyncingContinuation)
        {
            for (var i = 0; i < AvailableSynchronizationRequestsTo(destination.FileSystemUrl); i++)
            {
                SynchronizationWorkItem work;
                if (!synchronizationQueue.TryDequePendingSynchronization(destination.FileSystemUrl, out work))
                {
                    break;
                }

                if (synchronizationQueue.IsDifferentWorkForTheSameFileBeingPerformed(work, destination.FileSystemUrl))
                {
                    Log.Debug("There was an already being performed synchronization of a file '{0}' to {1}", work.FileName,
                              destination);
                    synchronizationQueue.EnqueueSynchronization(destination.FileSystemUrl, work);                     // add it again at the end of the queue
                }
                else
                {
                    var workTask = PerformSynchronizationAsync(destination, work);

                    if (forceSyncingContinuation)
                    {
                        workTask.ContinueWith(t => SynchronizePendingFilesAsync(destination, true).ToArray());
                    }
                    yield return(workTask);
                }
            }
        }
Exemplo n.º 2
0
        private IEnumerable <Task <SynchronizationReport> > SynchronizePendingFilesAsync(IAsyncFilesSynchronizationCommands destination, bool forceSyncingContinuation)
        {
            var commands = (IAsyncFilesCommandsImpl)destination.Commands;

            var destinationUrl = commands.UrlFor();

            for (var i = 0; i < AvailableSynchronizationRequestsTo(destinationUrl); i++)
            {
                SynchronizationWorkItem work;
                if (!synchronizationQueue.TryDequePendingSynchronization(destinationUrl, out work))
                {
                    break;
                }

                if (synchronizationQueue.IsDifferentWorkForTheSameFileBeingPerformed(work, destinationUrl))
                {
                    Log.Debug("There was an already being performed synchronization of a file '{0}' to {1}", work.FileName,
                              destination);

                    if (synchronizationQueue.EnqueueSynchronization(destinationUrl, work)) // add it again at the end of the queue
                    {
                        // add it again at the end of the queue
                        publisher.Publish(new SynchronizationUpdateNotification
                        {
                            FileName = work.FileName,
                            DestinationFileSystemUrl = destinationUrl,
                            SourceServerId           = storage.Id,
                            SourceFileSystemUrl      = FileSystemUrl,
                            Type   = work.SynchronizationType,
                            Action = SynchronizationAction.Enqueue,
                            SynchronizationDirection = SynchronizationDirection.Outgoing
                        });
                    }
                }
                else
                {
                    var workTask = PerformSynchronizationAsync(destination, work);

                    if (forceSyncingContinuation)
                    {
                        workTask.ContinueWith(t => SynchronizePendingFilesAsync(destination, true).ToArray());
                    }
                    yield return(workTask);
                }
            }
        }