Add log messages in DropboxService

This commit is contained in:
Tobias Eidelpes 2021-01-08 12:20:25 +01:00
parent 36226186a0
commit 94ffac4984

View File

@ -64,16 +64,21 @@ class DropboxService(StorageServiceInterface):
:param file: bytes representation of the file :param file: bytes representation of the file
:return: Whether file was successfully uploaded :return: Whether file was successfully uploaded
""" """
identifier = filename.strip('.jpg')
print("DropboxService: Trying to update file with identifier ", identifier)
i = 0 i = 0
while True: while True:
try: try:
dbx = dropbox.Dropbox(settings.DROPBOX_OAUTH2_ACCESS_TOKEN) dbx = dropbox.Dropbox(settings.DROPBOX_OAUTH2_ACCESS_TOKEN)
dbx.files_get_metadata(filename + '_' + str(i)) print("DropboxService: Checking if version %s exists".format(identifier + '_' + str(i) + '.jpg'))
dbx.files_get_metadata(identifier + '_' + str(i) + '.jpg')
i = i + 1 i = i + 1
except: except:
print("DropboxService: Version %s exists".format(identifier + '_' + str(i) + '.jpg'))
break break
return DropboxService.create_file(filename + '_' + str(i), file) print("DropboxService: Creating new version %s".format(identifier + '_' + str(i) + '.jpg'))
return DropboxService.create_file(identifier + '_' + str(i) + '.jpg', file)
@staticmethod @staticmethod
def delete_file(filename: str) -> bool: def delete_file(filename: str) -> bool: