/// <summary> Saves a backup of the map and associated files. (like bots, .properties) </summary> /// <param name="force"> Whether to save a backup, even if nothing changed since last one. </param> /// <param name="backup"> Specific name of the backup, or "" to automatically pick a name. </param> /// <returns> The name of the backup, or null if no backup was saved. </returns> public string Backup(bool force = false, string backup = "") { if (!backedup || force) { string backupPath = LevelInfo.BackupBasePath(name); if (!Directory.Exists(backupPath)) { Directory.CreateDirectory(backupPath); } int next = LevelInfo.LatestBackup(name) + 1; if (backup.Length == 0) { backup = next.ToString(); } if (!LevelActions.Backup(name, backup)) { Logger.Log(LogType.Warning, "FAILED TO INCREMENTAL BACKUP :" + name); return(null); } return(backup); } Logger.Log(LogType.SystemActivity, "Level unchanged, skipping backup"); return(null); }
/// <summary> Saves a backup of the map and associated files. (like bots, .properties) </summary> /// <param name="force"> Whether to save a backup, even if nothing changed since last one. </param> /// <param name="backup"> Specific name of the backup, or "" to automatically pick a name. </param> /// <returns> The name of the backup, or null if no backup was saved. </returns> public string Backup(bool force = false, string backup = "") { if (ChangedSinceBackup || force) { if (backup.Length == 0) { backup = LevelInfo.NextBackup(name); } if (!LevelActions.Backup(name, backup)) { Logger.Log(LogType.Warning, "FAILED TO INCREMENTAL BACKUP :" + name); return(null); } return(backup); } Logger.Log(LogType.SystemActivity, "Level unchanged, skipping backup"); return(null); }
public static bool Backup(Player p, Level lvl, string backup) { string map = lvl.name; bool auto = backup.Length == 0; if (auto) { backup = LevelInfo.NextBackup(map); } TimeSpan delta = lvl.lastBackup - DateTime.UtcNow; if (delta.TotalSeconds >= 0) { p.Message("You must wait another {0} to backup {1} &Sagain", delta.Shorten(true, true), lvl.ColoredName); return(false); } lvl.lastBackup = DateTime.UtcNow.AddSeconds(10); if (!LevelActions.Backup(map, backup)) { p.Message("&WFailed to backup {0}", lvl.ColoredName); return(false); } if (auto) { Logger.Log(LogType.SystemActivity, "Backup {1} saved for {0}", map, backup); lvl.Message("Backup " + backup + " saved for " + lvl.ColoredName); } else { Logger.Log(LogType.SystemActivity, "{0} had a backup created named &b{1}", map, backup); lvl.Message(lvl.ColoredName + " &Shad a backup created named &b" + backup); } return(true); }