summaryrefslogtreecommitdiff
path: root/fbin/file_storage/base.py
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2020-10-28 20:14:05 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2020-10-28 20:14:05 +0100
commitb1ed551c3125278d14a69750fea2bfe39cf68530 (patch)
treefe7a89bd5bea3d53b18009a55e29b9f4181ca600 /fbin/file_storage/base.py
parent0faa732c9a3e1ffced2b26bee682f513b0e5f0ae (diff)
Add fbin-backup.py
This is a backup script which will copy files to a target storage, and optionally add database entries as well. It works by specifying a source and a target config file. Both should have separate storage configured, and files will be copied from the source storage to the target storage. The list of files to copy is read from the source database, which means this must be accessible from where the script is run, not just the storage. If updating databse entries the target database must also be accessible. The target database is also check for any existing file hashes, and any files that would cause a collision will be skipped.
Diffstat (limited to 'fbin/file_storage/base.py')
-rw-r--r--fbin/file_storage/base.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/fbin/file_storage/base.py b/fbin/file_storage/base.py
index abdf580..aa2c510 100644
--- a/fbin/file_storage/base.py
+++ b/fbin/file_storage/base.py
@@ -13,6 +13,10 @@ class BaseStorage:
if size_limit is not None and file.size > size_limit:
raise FileSizeError('The file size is too large (max {})'.format(File.pretty_size(size_limit)))
+ def upload_file(self, uploaded_file, file_hash, user):
+ '''Upload data from uploaded_file.'''
+ raise NotImplementedError()
+
def add_file(self, file_hash, filename, size, user=None, ip=None, verify=True):
'''Adds the file to the database.
@@ -29,6 +33,10 @@ class BaseStorage:
'''Store uploaded_file.'''
raise NotImplementedError()
+ def file_exists(self, f):
+ '''Return True if the specified file exists. '''
+ raise NotImplementedError()
+
def get_file(self, f):
'''Return a file object for the specified file.