Ejemplo n.º 1
0
        public static async Task <uint> GetFileDataIDByFilename(string buildConfig, string cdnConfig, string filename)
        {
            var build = await BuildCache.GetOrCreate(buildConfig, cdnConfig);

            using var hasher = new Jenkins96();
            var lookup = hasher.ComputeHash(filename, true);

            if (build.root.entriesLookup.TryGetValue(lookup, out var entry))
            {
                return(entry[0].fileDataID);
            }

            return(0);
        }
Ejemplo n.º 2
0
        public static async Task <bool> FileExists(string buildConfig, string filename)
        {
            var build = await BuildCache.GetOrCreate(buildConfig);

            using (var hasher = new Jenkins96())
            {
                var lookup = hasher.ComputeHash(filename, true);

                if (build.root.entriesLookup.ContainsKey(lookup))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        public static byte[] GetFileByFilename(string buildConfig, string cdnConfig, string filename)
        {
            if (!buildDictionary.ContainsKey(buildConfig))
            {
                LoadBuild("wowt", buildConfig, cdnConfig);
            }

            var build = buildDictionary[buildConfig];

            var hasher = new Jenkins96();
            var lookup = hasher.ComputeHash(filename, true);
            var target = "";

            if (build.root.entriesLookup.TryGetValue(lookup, out var entry))
            {
                RootEntry?prioritizedEntry = entry.FirstOrDefault(subentry =>
                                                                  subentry.contentFlags.HasFlag(ContentFlags.LowViolence) == false && (subentry.localeFlags.HasFlag(LocaleFlags.All_WoW) || subentry.localeFlags.HasFlag(LocaleFlags.enUS))
                                                                  );

                var selectedEntry = (prioritizedEntry != null) ? prioritizedEntry.Value : entry.First();
                target = selectedEntry.md5.ToHexString().ToLower();
            }

            if (string.IsNullOrEmpty(target))
            {
                var filedataid = Database.GetFileDataIDByFilename(filename);
                if (filedataid != 0)
                {
                    if (build.root.entriesFDID.TryGetValue(filedataid, out var fdidentry))
                    {
                        RootEntry?prioritizedEntry = fdidentry.FirstOrDefault(subentry =>
                                                                              subentry.contentFlags.HasFlag(ContentFlags.LowViolence) == false && (subentry.localeFlags.HasFlag(LocaleFlags.All_WoW) || subentry.localeFlags.HasFlag(LocaleFlags.enUS))
                                                                              );

                        var selectedEntry = (prioritizedEntry != null) ? prioritizedEntry.Value : fdidentry.First();
                        target = selectedEntry.md5.ToHexString().ToLower();
                    }
                }
            }

            if (string.IsNullOrEmpty(target))
            {
                throw new FileNotFoundException("No file found in root for filename " + filename);
            }

            return(GetFile(buildConfig, cdnConfig, target));
        }
Ejemplo n.º 4
0
        public static bool FileExists(string buildConfig, string cdnConfig, string filename)
        {
            if (!buildDictionary.ContainsKey(buildConfig))
            {
                LoadBuild("wowt", buildConfig, cdnConfig);
            }

            var hasher = new Jenkins96();
            var lookup = hasher.ComputeHash(filename, true);

            if (buildDictionary[buildConfig].root.entriesLookup.ContainsKey(lookup))
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 5
0
        public static uint GetFileDataIDByFilename(string buildConfig, string cdnConfig, string filename)
        {
            if (!buildDictionary.ContainsKey(buildConfig))
            {
                LoadBuild("wowt", buildConfig, cdnConfig);
            }

            var build = buildDictionary[buildConfig];

            var hasher = new Jenkins96();
            var lookup = hasher.ComputeHash(filename, true);

            if (build.root.entriesLookup.TryGetValue(lookup, out var entry))
            {
                return(entry[0].fileDataID);
            }

            return(0);
        }
Ejemplo n.º 6
0
        public async static Task <byte[]> GetFileByFilename(string buildConfig, string cdnConfig, string filename, LocaleFlags locale = LocaleFlags.All_WoW)
        {
            var build = await BuildCache.GetOrCreate(buildConfig, cdnConfig);

            using var hasher = new Jenkins96();
            var lookup = hasher.ComputeHash(filename, true);
            var target = "";

            if (build.root.entriesLookup.TryGetValue(lookup, out var entry))
            {
                RootEntry prioritizedEntry;

                if (locale == LocaleFlags.All_WoW)
                {
                    prioritizedEntry = entry.FirstOrDefault(subentry =>
                                                            subentry.contentFlags.HasFlag(ContentFlags.LowViolence) == false && (subentry.localeFlags.HasFlag(LocaleFlags.All_WoW) || subentry.localeFlags.HasFlag(LocaleFlags.enUS))
                                                            );
                }
                else
                {
                    prioritizedEntry = entry.FirstOrDefault(subentry =>
                                                            subentry.contentFlags.HasFlag(ContentFlags.LowViolence) == false && subentry.localeFlags.HasFlag(locale)
                                                            );
                }

                var selectedEntry = (prioritizedEntry.fileDataID != 0) ? prioritizedEntry : entry.First();
                target = selectedEntry.md5.ToHexString().ToLower();
            }

            if (string.IsNullOrEmpty(target))
            {
                var filedataid = await Database.GetFileDataIDByFilename(filename);

                if (filedataid != 0)
                {
                    if (build.root.entriesFDID.TryGetValue(filedataid, out var fdidentry))
                    {
                        RootEntry prioritizedEntry;

                        if (locale == LocaleFlags.All_WoW)
                        {
                            prioritizedEntry = fdidentry.FirstOrDefault(subentry =>
                                                                        subentry.contentFlags.HasFlag(ContentFlags.LowViolence) == false && (subentry.localeFlags.HasFlag(LocaleFlags.All_WoW) || subentry.localeFlags.HasFlag(LocaleFlags.enUS))
                                                                        );
                        }
                        else
                        {
                            prioritizedEntry = fdidentry.FirstOrDefault(subentry =>
                                                                        subentry.contentFlags.HasFlag(ContentFlags.LowViolence) == false && subentry.localeFlags.HasFlag(locale)
                                                                        );
                        }

                        var selectedEntry = (prioritizedEntry.fileDataID != 0) ? prioritizedEntry : fdidentry.First();
                        target = selectedEntry.md5.ToHexString().ToLower();
                    }
                }
            }

            if (string.IsNullOrEmpty(target))
            {
                throw new FileNotFoundException("No file found in root for filename " + filename);
            }

            return(await GetFile(buildConfig, cdnConfig, target));
        }