Esempio n. 1
0
        public BuildData New(uint number)
        {
            var _path = Path.Combine(buildPath, number.ToString());

            PathEx.CreatePath(_path);

            var buildData = new BuildData {
                Number      = number,
                ContentPath = _path,
                Created     = DateTime.UtcNow,
            };

            data[number] = buildData;
            return(buildData);
        }
Esempio n. 2
0
        public void Load()
        {
            if (!Directory.Exists(buildPath))
            {
                return;
            }

            foreach (var path in Directory.EnumerateDirectories(buildPath, "*", SearchOption.TopDirectoryOnly))
            {
                var path_name = Path.GetFileName(path);

                if (!uint.TryParse(path_name, out var buildNumber))
                {
                    Log.Warn($"Failed to parse build directory '{path_name}'!");
                    continue;
                }

                var       indexFilename = Path.Combine(path, "index.json");
                BuildData buildData;

                if (File.Exists(indexFilename))
                {
                    using (var stream = File.Open(indexFilename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
                        buildData             = JsonSettings.Serializer.Deserialize <BuildData>(stream);
                        buildData.ContentPath = path;
                    }
                }
                else
                {
                    buildData = new BuildData {
                        Number      = buildNumber,
                        ContentPath = path,
                    };
                }

                data[buildNumber] = buildData;
            }
        }
Esempio n. 3
0
 public bool TryGet(uint number, out BuildData buildData)
 {
     return(data.TryGetValue(number, out buildData));
 }