Fix type mismatches in save file rotation
authorJeremy Stanley <fungi@yuggoth.org>
Mon, 29 Dec 2014 20:21:49 +0000 (20:21 +0000)
committerJeremy Stanley <fungi@yuggoth.org>
Mon, 29 Dec 2014 20:21:49 +0000 (20:21 +0000)
The numeric suffix on rotated save files needs to be treated as an
int during rotation calculations but as a str during filename
generation. Make it so.

lib/mudpy/data.py

index b7d173b..3eddc43 100644 (file)
@@ -133,13 +133,13 @@ class DataFile:
                 backups.reverse()
                 for old_backup in backups:
                     if old_backup >= max_count - 1:
-                        os.remove(self.filename + "." + old_backup)
+                        os.remove(self.filename + "." + str(old_backup))
                     elif not os.path.exists(
-                        self.filename + "." + old_backup + 1
+                        self.filename + "." + str(old_backup + 1)
                     ):
                         os.rename(
-                            self.filename + "." + old_backup,
-                            self.filename + "." + old_backup + 1
+                            self.filename + "." + str(old_backup),
+                            self.filename + "." + str(old_backup + 1)
                         )
                 if not os.path.exists(self.filename + ".0"):
                     os.rename(self.filename, self.filename + ".0")