Ejemplo n.º 1
0
        public async Task <FileResult> GetSingleFile(string path)
        {
            if (!File.Exists(path))
            {
                return(null);
            }

            FileResult returnValue = _db.GetFileResult(path);

            // File exists in the database, return now
            if (returnValue != null)
            {
                _log.Information($"File {path} already exists in database. Match ID: {returnValue.ReplayFile.MatchId}");
                return(returnValue);
            }

            var replayFileInfo = _fileSystem.GetSingleReplayFileInfo(path);
            var parseResult    = await _reader.ReadFile(path).ConfigureAwait(false);

            var newResult = new FileResult(replayFileInfo, parseResult)
            {
                IsNewFile = false
            };

            _db.AddFileResult(newResult);

            return(newResult);
        }