Copy file and maybe copy stats. fix #349

This commit is contained in:
Ruud
2013-09-02 16:49:57 +02:00
parent 3e28cd5c95
commit bc77812488
2 changed files with 11 additions and 1 deletions
@@ -48,6 +48,11 @@ class MetaDataBase(Plugin):
log.debug('Creating %s file: %s', (file_type, name))
if os.path.isfile(content):
shutil.copy2(content, name)
shutil.copyfile(content, name)
# Try and copy stats seperately
try: shutil.copystat(content, name)
except: pass
else:
self.createFile(name, content)
group['renamed_files'].append(name)
+6 -1
View File
@@ -89,7 +89,12 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
src_files = [options.config_file, db_path, db_path + '-shm', db_path + '-wal']
for src_file in src_files:
if os.path.isfile(src_file):
shutil.copy2(src_file, toUnicode(os.path.join(new_backup, os.path.basename(src_file))))
dst_file = toUnicode(os.path.join(new_backup, os.path.basename(src_file)))
shutil.copyfile(src_file, dst_file)
# Try and copy stats seperately
try: shutil.copystat(src_file, dst_file)
except: pass
# Remove older backups, keep backups 3 days or at least 3
backups = []