]> git.parisson.com Git - telemeta.git/commitdiff
fix backup path
authorGuillaume Pellerin <yomguy@parisson.com>
Mon, 9 Mar 2015 17:01:20 +0000 (18:01 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Mon, 9 Mar 2015 17:01:20 +0000 (18:01 +0100)
telemeta/backup/core.py
tools/scripts/telemeta-backup.py

index 16f3b9b5181093cbfacdfeec970a7c5e34ea5887..833a4bbc18f7ad6173a00501fa9cfc27bdbb4284 100644 (file)
@@ -44,11 +44,8 @@ from telemeta.models import MediaItem
 class CollectionSerializer(object):
     """Provide backup-related features"""
 
-    def __init__(self, collection, dest_dir='.'):
+    def __init__(self, collection, dest_dir='/tmp/'):
         self.collection = collection
-        self.coll_dir = dest_dir + "/" + str(self.collection.id)
-        if not os.path.exists(self.coll_dir):
-            os.makedirs(self.coll_dir)
 
     def __get_file_md5(self, path):
         "Compute the MD5 hash of a file (Python version of md5sum)"
@@ -65,6 +62,14 @@ class CollectionSerializer(object):
     def __get_media_filename(self, item):
         return str(item.id) + ".wav"
 
+    def backup(self, dest_dir):
+        self.coll_dir = dest_dir + "/" + str(self.collection.id)
+        if not os.path.exists(self.coll_dir):
+            os.makedirs(self.coll_dir)
+        self.store_json()
+        self.store_xml()
+        self.store_files()
+
     def store_files(self):
         if self.collection.has_mediafile():
             md5_file = open(self.coll_dir + "/MD5SUM", "wb")
index 2ccf009466a6f73fa1362441293bab9b3fa8f8dd..0a314998d04ee4d7504de57ed28beef1e3469b7d 100755 (executable)
@@ -75,7 +75,7 @@ def backup(dest_dir):
             % (i, count, i*100/count, collection.id),
         sys.stdout.flush()
         serializer = CollectionSerializer(collection)
-        serializer.store(set_dir)
+        serializer.backup(set_dir)
         print "Done"
 
 def run():
@@ -89,6 +89,6 @@ def run():
         import settings
         setup_environ(settings)
         backup(backup_dir)
-        
+
 if __name__ == '__main__':
     run()