From b09c4a92dc1c2920892d8900ab6d3032620df3c2 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Mon, 9 Mar 2015 18:01:20 +0100 Subject: [PATCH] fix backup path --- telemeta/backup/core.py | 13 +++++++++---- tools/scripts/telemeta-backup.py | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/telemeta/backup/core.py b/telemeta/backup/core.py index 16f3b9b5..833a4bbc 100644 --- a/telemeta/backup/core.py +++ b/telemeta/backup/core.py @@ -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") diff --git a/tools/scripts/telemeta-backup.py b/tools/scripts/telemeta-backup.py index 2ccf0094..0a314998 100755 --- a/tools/scripts/telemeta-backup.py +++ b/tools/scripts/telemeta-backup.py @@ -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() -- 2.39.5