예제 #1
0
        private void ProcessInputStartUpdate()
        {
            Uploadable.BeginUpdate();
            Uploadable.Items.Clear();
            Uploadable.Groups.Clear();

            Uploaded.BeginUpdate();
            Uploaded.Items.Clear();
            Uploaded.Groups.Clear();

            Available.BeginUpdate();
            Available.Items.Clear();
            Available.Groups.Clear();
        }
예제 #2
0
 private void ProcessInputEndUpdate()
 {
     Uploadable.EndUpdate();
     Uploaded.EndUpdate();
     Available.EndUpdate();
 }
예제 #3
0
        internal void Tick(float dt)
        {
            lock (_uploadQueue)
            {
                while (_uploadsInFlight.Count < kMaxSimultaneousUploads && _uploadQueue.Count > 0)
                {
                    var path = _uploadQueue.Dequeue();
                    if (!_uploadsInFlight.ContainsKey(path))
                    {
                        FileStream file = null;
                        try
                        {
                            file = File.OpenRead(path);
                        }
                        catch (Exception e)
                        {
                            Log.E($"{_ServiceName()} Failed to open the file {path} for upload. Exception: {e.Message}", kUseConsoleLog);
                            continue;
                        }

                        var isArtifact = true;
                        _uploadIsArtifact.TryGetValue(path, out isArtifact);
                        var task = UploadAsync(file, LocalPathToObjectPath(path), isArtifact);
                        if (task == null)
                        {
                            Log.E($"{_ServiceName()} failed to upload file {path} asynchronously.", kUseConsoleLog);
                            continue;
                        }
                        var uploadable = new Uploadable(path, task);
                        uploadable.source = file;
                        _uploadsInFlight.Add(path, uploadable);
                    }
                }
            }

            foreach (var kv in _uploadsInFlight)
            {
                var path       = kv.Key;
                var uploadable = kv.Value;
                Debug.Assert(typeof(Uploadable).IsValueType == false);

                switch (uploadable.task.Status)
                {
                case TaskStatus.Canceled:
                    uploadable.Cleanup();
                    _keysToRemove.Add(path);
                    Log.V($"{_ServiceName()} upload canceled for {path}", kUseConsoleLog);
                    break;

                case TaskStatus.Faulted:
                    if (Manager.FinalUploadsDone)
                    {
                        uploadable.Cleanup();
                        _keysToRemove.Add(path);
                        Log.I($"{_ServiceName()} Shutdown in progress, ignoring retry for {path}", kUseConsoleLog);
                        break;
                    }
                    if (++uploadable.attempts > kMaxUploadRetryAttempts)
                    {
                        uploadable.Cleanup();
                        _keysToRemove.Add(path);
                        Log.V($"{_ServiceName()} Exceeded upload attempts for {path}.", kUseConsoleLog);
                    }
                    else
                    {
                        try
                        {
                            uploadable.source = File.OpenRead(path);
                        }
                        catch (Exception e)
                        {
                            Log.E($"{_ServiceName()} Failed to open the file {path} for upload. Exception: {e.Message}.", kUseConsoleLog);
                            break;
                        }

                        var isArtifact = true;
                        _uploadIsArtifact.TryGetValue(path, out isArtifact);
                        uploadable.task = UploadAsync(uploadable.source, LocalPathToObjectPath(path), isArtifact);
                        if (uploadable.task == null)
                        {
                            Log.E($"{_ServiceName()} failed to upload {path} asynchronously.", kUseConsoleLog);
                            uploadable.Cleanup();
                            _keysToRemove.Add(path);
                            break;
                        }
                        Log.V($"{_ServiceName()} upload faulted, retrying attempt {uploadable.attempts} for {path}");
                    }
                    break;

                case TaskStatus.RanToCompletion:
                    uploadable.Cleanup();
                    if (Options.removeLocalFilesAfterUpload && Configuration.Instance.IsSimulationRunningInCloud())
                    {
                        Log.V($"{_ServiceName()} Removing local file {path}", kUseConsoleLog);
                        File.Delete(path);
                    }
                    _keysToRemove.Add(path);
                    break;
                }
            }

            foreach (var k in _keysToRemove)
            {
                _uploadsInFlight.Remove(k);
                if (_uploadIsArtifact.ContainsKey(k))
                {
                    _uploadIsArtifact.Remove(k);
                }
            }
            _keysToRemove.Clear();
        }