Ejemplo n.º 1
0
        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 */ } {
        }
Ejemplo n.º 2
0
        internal void OnFileTransfered(string zipName)
        {
            GUI.Instance.ResetProgressStatus(1);

            GUI.Instance.UpdateStatus(0, "Unpacking update...");

            bool isLegacy = this.filteredUpdates[this.currentIndex].IsLegacy;

            string zipPath = string.Format(@"{0}\Downloads\{1}", zipName);

            string fileName = filteredUpdates[currentIndex].FileName;

            if (isLegacy)
            {
                GUI.Instance.UpdateStatus(1, string.Format("Moving {0} to /Resource/...", fileName));

                // Extract the zip to the /resource/ folder of client
                ZIP.Unpack(zipPath, resourceFolder);
            }
            else
            {
                string filePath = string.Format(@"{0}\{1}", tmpDirectory, fileName);

                // Extract the zip to the /tmp/ folder for processing
                ZIP.Unpack(zipPath, tmpDirectory);

                DataCore.Structures.IndexEntry indexEntry = Core.GetEntry(ref index, fileName);

                if (indexEntry != null)
                {
                    GUI.Instance.UpdateStatus(0, string.Format("Updating indexed file: {0}...", fileName));

                    Core.UpdateFileEntry(ref index, settings.GetString("clientdirectory"), filePath, 0);

                    Core.Save(ref index, settings.GetString("clientdirectory"), false, false);
                }
            }

            GUI.Instance.UpdateStatus(1, "Cleaning up...");

            // Delete the zip
            File.Delete(zipPath);

            if (this.currentIndex == this.FileList.Count)
            {
                GUI.Instance.OnUpdateComplete();
            }
        }
Ejemplo n.º 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();
                }
            }
        }