예제 #1
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();
            }
        }
예제 #2
0
        public void OnFileTransfered(string zipName)
        {
            GUI.Instance.ResetProgressStatus(1);

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

            string fileName = FileList[currentIndex].FileName;

            bool isLegacy = updatingResource;

            bool isNew = !Core.EntryExists(ref index, fileName);

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


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

                // TODO: Rename? Move? Delete if already exists

                // 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)
                {
                    if (!isNew)
                    {
                        GUI.Instance.UpdateStatus(1, string.Format("Updating indexed file: {0}...", fileName));
                        Core.UpdateFileEntry(ref index, settings.GetString("clientdirectory"), filePath, 0);
                    }
                    else
                    {
                        GUI.Instance.UpdateStatus(1, string.Format("Inserting file: {0}...", fileName));
                        Core.ImportFileEntry(ref index, settings.GetString("clientdirectory"), filePath, 0);
                    }

                    GUI.Instance.UpdateStatus(1, "Finalizing data index...");
                    Core.Save(ref index, settings.GetString("clientdirectory"), false);
                }
            }

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

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

            // Clear the tmp folder
            foreach (string tmpFileName in Directory.GetFiles(tmpDirectory))
            {
                File.Delete(tmpFileName);
            }

            // Increase the currentIndex
            iterateCurrentIndex();
        }