import shutil
import tarfile
+import tempfile
import subprocess
import os.path
import os
'--mongorestore_path', default='mongorestore',
help='mongorestore binary')
subparser.add_argument(
- '--cache_path', default='/tmp/mediagoblin/',
- help='')
+ '--cache_path',
+ help='Temporary directory where files will be temporarily dumped')
def _import_media(db, args):
"""
Restore mongo database and media files from a tar archive
"""
+ if not args.cache_path:
+ args.cache_path = tempfile.mkdtemp()
+
# args.cache_path += 'mediagoblin-data'
setup_global_and_app_config(args.conf_file)
return False
- if os.path.exists(args.cache_path):
- print 'The cache directory must not exist before you run this script'
- print 'Cache directory: ', args.cache_path
-
- return False
-
return True
"""
Export database and media files to a tar archive
"""
+ if args.cache_path:
+ if os.path.exists(args.cache_path):
+ print 'The cache directory must not exist before you run this script'
+ print 'Cache directory: ', args.cache_path
+
+ return False
+ else:
+ args.cache_path = tempfile.mkdtemp()
+
args = _setup_paths(args)
if not _export_check(args):