Exemple #1
0
        public static void Extract(Player p)
        {
            int errors = 0;

            using (FileStream src = File.OpenRead(zipPath)) {
                ZipReader reader = new ZipReader(src);
                reader.FindFooter();
                int entries = reader.FindEntries();
                p.Message("Restoring {0} files", entries);

                for (int i = 0; i < entries; i++)
                {
                    string path = ExtractItem(reader, i, ref errors);
                    if (i > 0 && (i % 100) == 0)
                    {
                        Logger.Log(LogType.SystemActivity, "Restored {0}/{1} files", i, entries);
                    }

                    if (!path.CaselessEq(sqlPath))
                    {
                        continue;
                    }
                    // If DB is in there, they backed it up, meaning they want it restored
                    using (Stream part = reader.GetEntry(i, out path)) {
                        ReplaceDatabase(part);
                    }
                }
            }

            // To make life easier, we reload settings now, to make it less likely to need restart
            Server.LoadAllSettings();
            p.Message("Server restored" + (errors > 0 ? " with errors. May be a partial restore" : ""));
            p.Message("It is recommended that you restart the server, although this is not required.");
        }