remove try catch, it is catched a step above to keep the exception information;
added additional parse try with: -payload = request.data.dict() -payload['metadata'] = json.loads(payload['metadata']); update metadata on update; prohibit . in filename;
This commit is contained in:
@@ -60,20 +60,13 @@ class MongoDBService:
|
||||
db = instance.AIC
|
||||
col = db.metadata
|
||||
|
||||
try:
|
||||
metadata['identifier'] = identifier
|
||||
metadata['location'] = [metadata['longitude'], metadata['latitude']]
|
||||
metadata['sha512'] = create_sha512(decoded_image)
|
||||
col.insert_one(metadata)
|
||||
|
||||
except:
|
||||
print("Could not insert Metadata")
|
||||
return False
|
||||
|
||||
return True
|
||||
metadata['identifier'] = identifier
|
||||
metadata['location'] = [metadata['longitude'], metadata['latitude']]
|
||||
metadata['sha512'] = create_sha512(decoded_image)
|
||||
col.insert_one(metadata)
|
||||
|
||||
@staticmethod
|
||||
def updateSingle(identifier, decoded_image) -> bool:
|
||||
def updateSingle(identifier, decoded_image, meta=None) -> bool:
|
||||
print("MongoDBService: Trying to update file with identifier " + identifier)
|
||||
instance = MongoManager.getInstance()
|
||||
db = instance.AIC
|
||||
@@ -87,6 +80,8 @@ class MongoDBService:
|
||||
identifier_changed = identifier + '_' + str(metadata_orig['version']) # Set identifier to include version
|
||||
metadata_new['version'] = str(int(metadata_new['version']) + 1) # Increment version by one
|
||||
|
||||
metadata_new.update(meta)
|
||||
|
||||
print("MongoDBService: identifier_changed: ", identifier_changed)
|
||||
col.update_one(old, {"$set": {"identifier": identifier_changed, "filename": identifier_changed + '.jpg'}})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user