decimal fixing
This commit is contained in:
parent
2de4a5d5ae
commit
a540a5aad2
@ -2,7 +2,8 @@ import os
|
||||
import cherrypy
|
||||
import json
|
||||
from datetime import datetime
|
||||
from photoapp.types import Photo, PhotoSet, Tag, PhotoStatus, User, known_extensions, known_mimes, genuuid
|
||||
from photoapp.types import Photo, PhotoSet, Tag, PhotoStatus, User, known_extensions, known_mimes, \
|
||||
genuuid, generate_storage_path
|
||||
from photoapp.utils import copysha, get_extension
|
||||
from photoapp.image import special_magic_fobj
|
||||
from photoapp.storage import StorageAdapter
|
||||
@ -61,7 +62,6 @@ class PhotosApiV1(object):
|
||||
# use the photo's date to build a base path
|
||||
# each file's sha and file extension will be appended to this
|
||||
photo_date = datetime.fromisoformat(meta["date"])
|
||||
basepath = photo_date.strftime("%Y/%m/%d/%Y-%m-%d_%H.%M.%S")
|
||||
photo_objs = []
|
||||
|
||||
for file in files:
|
||||
@ -70,7 +70,7 @@ class PhotosApiV1(object):
|
||||
photo_meta = meta["files"][file.filename]
|
||||
ext = get_extension(file.filename)
|
||||
assert ext in known_extensions
|
||||
photo_path = f"{basepath}_{photo_meta['hash'][0:8]}.{ext}"
|
||||
photo_path = generate_storage_path(photo_date, photo_meta['hash'][0:8], ext)
|
||||
|
||||
if self.library.storage.exists(photo_path):
|
||||
return abort_upload(f"file already in library: {photo_path}")
|
||||
|
@ -40,6 +40,11 @@ def map_extension(ext):
|
||||
return ext
|
||||
|
||||
|
||||
def generate_storage_path(timestamp, sha, extension):
|
||||
basepath = timestamp.strftime("%Y/%m/%d/%Y-%m-%d_%H.%M.%S")
|
||||
return f"{basepath}_{sha[0:8]}.{extension.lower()}"
|
||||
|
||||
|
||||
class PhotoStatus(enum.Enum):
|
||||
private = 0
|
||||
public = 1
|
||||
@ -54,8 +59,8 @@ class PhotoSet(Base):
|
||||
date = Column(DateTime)
|
||||
date_real = Column(DateTime)
|
||||
date_offset = Column(Integer, default=0) # minutes
|
||||
lat = Column(DECIMAL(precision=11))
|
||||
lon = Column(DECIMAL(precision=11))
|
||||
lat = Column(DECIMAL(precision=11, scale=8))
|
||||
lon = Column(DECIMAL(precision=11, scale=8))
|
||||
|
||||
files = relationship("Photo", back_populates="set")
|
||||
tags = relationship("TagItem", back_populates="set")
|
||||
|
Loading…
Reference in New Issue
Block a user