summaryrefslogtreecommitdiffstats
path: root/pyfirstaidkit/utils
diff options
context:
space:
mode:
authorMartin Sivak <msivak@redhat.com>2008-08-07 18:26:50 +0200
committerMartin Sivak <msivak@redhat.com>2008-08-07 18:26:50 +0200
commitd26d9504b6eced4cebe9c81f304858a45725a1ee (patch)
tree93a547fc41061005e0dfdae4a7d224287d21c0cf /pyfirstaidkit/utils
parentc47ac6a556445e37dbb74fb7673ef4d9c697e629 (diff)
downloadfirstaidkit-d26d9504b6eced4cebe9c81f304858a45725a1ee.tar.gz
firstaidkit-d26d9504b6eced4cebe9c81f304858a45725a1ee.tar.xz
firstaidkit-d26d9504b6eced4cebe9c81f304858a45725a1ee.zip
Do the persistent backup space in better way
Diffstat (limited to 'pyfirstaidkit/utils')
-rw-r--r--pyfirstaidkit/utils/backup.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/pyfirstaidkit/utils/backup.py b/pyfirstaidkit/utils/backup.py
index 96c7677..f7670c2 100644
--- a/pyfirstaidkit/utils/backup.py
+++ b/pyfirstaidkit/utils/backup.py
@@ -24,6 +24,7 @@ import shutil
import hashlib
import weakref
import cPickle as pickle
+import copy
class BackupException(Exception):
pass
@@ -49,18 +50,16 @@ class BackupStoreInterface(object):
raise NotImplemented()
def cleanup(self):
raise NotImplemented()
+ def cleanup_persistent(self):
+ raise NotImplemented()
def exists(self, name = None, path = None):
raise NotImplemented()
- class PersistentBackup(BackupStoreInterface.Backup):
- def cleanup(self):
- return False
-
def __init__(self):
raise NotImplemented()
- def getBackup(self, id):
+ def getBackup(self, id, persistent = False):
raise NotImplemented()
def closeBackup(self, id):
@@ -184,6 +183,9 @@ class FileBackupStore(BackupStoreInterface):
self.delete(name)
os.rmdir(self._path)
return True
+
+ def cleanup_persistent(self):
+ return False
def exists(self, name=None, path=None):
if name == None and path == None:
@@ -207,10 +209,6 @@ class FileBackupStore(BackupStoreInterface):
return False
- class PersistentBackup(FileBackupStore.Backup):
- def cleanup(self):
- return False
-
def __init__(self, path):
if self.__class__._singleton:
raise BackupException("BackupStore with %s type can have only "
@@ -228,9 +226,11 @@ class FileBackupStore(BackupStoreInterface):
self.__class__._singleton = weakref.proxy(self)
print("Backup system initialized")
- def getBackup(self, id):
+ def getBackup(self, id, persistent = False):
if not self._backups.has_key(id):
self._backups[id] = self.Backup(id, self._path+"/"+id+"/")
+ if persistent:
+ self._backups[id].cleanup = self._backups[id].cleanup_persistent
return self._backups[id]
def closeBackup(self, id):
@@ -250,6 +250,9 @@ class FileBackupStore(BackupStoreInterface):
if backupEmpty:
os.rmdir(self._path)
+ else:
+ print("I'm keeping persistent backup spaces intact")
+
print("Backup closed")