tune max upload size
parent
a540a5aad2
commit
92a20f4f58
|
@ -12,4 +12,5 @@ styles/mincss/
|
|||
testenv/
|
||||
source/
|
||||
source_copy/
|
||||
raws/
|
||||
raws/
|
||||
*.sql
|
||||
|
|
14
README.md
14
README.md
|
@ -114,19 +114,19 @@ This would ingest all the files listed in `shas.txt` that aren't already in the
|
|||
|
||||
Roadmap
|
||||
-------
|
||||
- Stateless aka docker support
|
||||
- Migration path
|
||||
- open database
|
||||
- copy files table to memory
|
||||
- recreate files table
|
||||
- insert into the new table, with replaced paths, generating a list of files moves at the same time
|
||||
- migrate files to the new storage according to the list
|
||||
- Flesh out CLI:
|
||||
- Relink function - make a photo a member of another photo
|
||||
- Config that is saved somewhere
|
||||
- Album features
|
||||
- Support additional fields on upload like title description tags etc
|
||||
- delete features
|
||||
- tag features
|
||||
- Tag on import
|
||||
- modify features (tags & images)
|
||||
- "Batch" tag on import
|
||||
- Generate a tag on import
|
||||
- Save it in config and re-use it (if passing --same-batch)
|
||||
- photos imported as a batch will be under 1 tag
|
||||
- Longer term ideas:
|
||||
- "fast ingest" method that touches the db/storage directly. This would scale better than the API ingest.
|
||||
- Dynamic svg placeholder for images we can't open
|
||||
|
|
|
@ -432,6 +432,10 @@ def main():
|
|||
default=os.environ.get("DATABASE_URL")),
|
||||
parser.add_argument('--debug', action="store_true", help="enable development options")
|
||||
|
||||
tunables = parser.add_argument_group(title="tunables")
|
||||
tunables.add_argument('--max-upload', help="maximum file upload size accepted in bytes",
|
||||
default=1024**3, type=int)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if not args.database:
|
||||
|
@ -493,7 +497,8 @@ def main():
|
|||
'server.socket_host': '0.0.0.0',
|
||||
'server.show_tracebacks': True,
|
||||
'log.screen': False,
|
||||
'engine.autoreload.on': args.debug
|
||||
'engine.autoreload.on': args.debug,
|
||||
'server.max_request_body_size': args.max_upload
|
||||
})
|
||||
|
||||
# Setup signal handling and run it.
|
||||
|
|
|
@ -38,33 +38,34 @@ class ThumbGenerator(object):
|
|||
return os.path.abspath(dest)
|
||||
if photo.width is None: # todo better detection of images that PIL can't open
|
||||
return None
|
||||
if photo.uuid not in self._failed_thumbs_cache[style]:
|
||||
thumb_width, thumb_height, flip_ok = styles[style]
|
||||
i_width = photo.width
|
||||
i_height = photo.height
|
||||
im_is_rotated = photo.orientation % 2 != 0 or i_height > i_width
|
||||
if photo.uuid in self._failed_thumbs_cache[style]:
|
||||
return None
|
||||
|
||||
if im_is_rotated and flip_ok:
|
||||
thumb_width, thumb_height = thumb_height, thumb_width
|
||||
thumb_width, thumb_height, flip_ok = styles[style]
|
||||
i_width = photo.width
|
||||
i_height = photo.height
|
||||
im_is_rotated = photo.orientation % 2 != 0 or i_height > i_width
|
||||
|
||||
thumb_width = min(thumb_width, i_width if i_width > 0 else 999999999) # TODO do we even have photo.width if PIL can't read the image?
|
||||
thumb_height = min(thumb_height, i_height if i_height > 0 else 999999999) # TODO this seems bad
|
||||
if im_is_rotated and flip_ok:
|
||||
thumb_width, thumb_height = thumb_height, thumb_width
|
||||
|
||||
# TODO have the subprocess download the file
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
fpath = os.path.join(tmpdir, "image")
|
||||
with self.library.storage.open(photo.path, 'rb') as fsrc:
|
||||
with open(fpath, 'wb') as fdest:
|
||||
copyfileobj(fsrc, fdest)
|
||||
thumb_width = min(thumb_width, i_width if i_width > 0 else 999999999) # TODO do we even have photo.width if PIL can't read the image?
|
||||
thumb_height = min(thumb_height, i_height if i_height > 0 else 999999999) # TODO this seems bad
|
||||
|
||||
p = Process(target=self.gen_thumb, args=(fpath, dest, thumb_width, thumb_height, photo.orientation))
|
||||
p.start()
|
||||
p.join()
|
||||
if p.exitcode != 0:
|
||||
self._failed_thumbs_cache[style][photo.uuid] = True # dont retry failed generations
|
||||
return None
|
||||
return os.path.abspath(dest)
|
||||
return None
|
||||
# TODO have the subprocess download the file
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
fpath = os.path.join(tmpdir, "image")
|
||||
with self.library.storage.open(photo.path, 'rb') as fsrc:
|
||||
with open(fpath, 'wb') as fdest:
|
||||
copyfileobj(fsrc, fdest)
|
||||
|
||||
p = Process(target=self.gen_thumb, args=(fpath, dest, thumb_width, thumb_height, photo.orientation))
|
||||
p.start()
|
||||
p.join()
|
||||
if p.exitcode != 0:
|
||||
self._failed_thumbs_cache[style][photo.uuid] = True # dont retry failed generations
|
||||
return None
|
||||
return os.path.abspath(dest)
|
||||
|
||||
@staticmethod
|
||||
def gen_thumb(src_img, dest_img, width, height, rotation):
|
||||
|
|
Loading…
Reference in New Issue