private void compareDataEntries()
        {
            GUI.Instance.UpdateStatus(0, "Comparing data entries...");
            GUI.Instance.UpdateProgressMaximum(0, FileList.Count);
            GUI.Instance.UpdateProgressValue(0, currentIndex);

            if (FileList.Count > 0)
            {
                Structures.IndexEntry file = FileList[currentIndex];

                DataCore.Structures.IndexEntry fileEntry = Core.GetEntry(ref index, file.FileName);

                if (fileEntry != null)
                {
                    GUI.Instance.UpdateStatus(1, string.Format("Checking {0}...", file.FileName));

                    string fileHash = Core.GetFileSHA512(settings.GetString("clientdirectory"), Core.GetID(fileEntry.Name), fileEntry.Offset, fileEntry.Length, GetFileExtension(fileEntry.Name));

                    if (file.FileHash != fileHash)
                    {
                        GUI.Instance.UpdateStatus(1, string.Format("Downloading {0}...", FileList[currentIndex].FileName));
                        downloadUpdate();
                    }
                }
                else /* TODO: Implement inserting new files */ } {
        }
Exemple #2
0
        private void compareResourceEntries()
        {
            GUI.Instance.UpdateStatus(0, "Comparing resource files...");
            GUI.Instance.UpdateProgressMaximum(0, FileList.Count);
            GUI.Instance.UpdateProgressValue(0, currentIndex);

            if (FileList.Count > 0)
            {
                Structures.IndexEntry file = FileList[currentIndex];

                if (file != null)
                {
                    string resourceName = string.Concat(resourceFolder, file.FileName);

                    if (!File.Exists(resourceName) || (Hash.GetSHA512Hash(resourceName) != file.FileHash))
                    {
                        GUI.Instance.UpdateStatus(1, string.Format("Downloading {0}...", FileList[currentIndex].FileName));
                        downloadUpdate();
                    }
                    else
                    {
                        iterateCurrentIndex();
                    }
                }
            }
            else
            {
                GUI.Instance.UpdateStatus(0, "Updating resource folder time...");
                Directory.SetLastWriteTimeUtc(resourceFolder, DateTime.UtcNow);

                iterateCurrentIndex();
            }
        }
Exemple #3
0
        protected void compareFiles()
        {
            guiInstance.UpdateStatus(0, "Checking client files...");
            GUI.Instance.UpdateProgressMaximum(0, FileList.Count);

            for (; currentIndex < FileList.Count; ++currentIndex)
            {
                guiInstance.UpdateProgressValue(0, currentIndex);

                Structures.IndexEntry file = FileList[currentIndex];
                bool download = false;

                guiInstance.UpdateStatus(1, string.Format("Checking file: {0}", file.FileName));

                if (file.IsLegacy)
                {
                    if (!File.Exists(resourceFolder + file.FileName) || (Hash.GetSHA512Hash(resourceFolder + file.FileName) != file.FileHash))
                    {
                        download = true;
                    }
                }
                else
                {
                    DataCore.Structures.IndexEntry fileEntry = Core.GetEntry(ref index, file.FileName);

                    if (fileEntry != null)
                    {
                        string fileHash = Core.GetFileSHA512(settings.GetString("clientdirectory"), Core.GetID(fileEntry.Name), fileEntry.Offset, fileEntry.Length, GetFileExtension(fileEntry.Name));

                        if (file.FileHash != fileHash)
                        {
                            guiInstance.UpdateStatus(1, string.Format("File: {0} is depreciated!", file.FileName));
                            download = true;
                        }
                    }
                }

                if (download)
                {
                    GUI.Instance.UpdateStatus(1, string.Format("Downloading {0}...", FileList[currentIndex].FileName));
                    doUpdate();
                }
            }
        }