Skip to content

Commit

Permalink
record failure into upload data
Browse files Browse the repository at this point in the history
  • Loading branch information
leafo committed Jan 20, 2021
1 parent 4c75b9a commit 7273d44
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cmd/detect_image_sizes.moon
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ for upload in pager\each_item!
continue
else
print "!!!!", "Failed to detect image"
upload\update_data {
error: "imagesize failed to detect image"
}
break


Expand All @@ -54,16 +57,17 @@ for upload in pager\each_item!

import to_json from require "lapis.util"

data_update = upload.data and {k,v for k,v in pairs upload.data} or {}
data_update.imagesize = {k,v for k,v in pairs data}
data_update.imagesize.type = image_type
imagesize_result = {k,v for k,v in pairs data}
imagesize_result.type = image_type

upload\update_data imagesize_result

upload\update {
width: data.width
height: data.height
data: to_json data_update
}


break

print "total:", count
9 changes: 9 additions & 0 deletions models/uploads.moon
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,12 @@ class Uploads extends Model
bucket = require("lapis.config").get!.storage_bucket
storage\get_file bucket, @bucket_key!, ...


update_data: (update) =>
new_data = @data and {k,v for k,v in pairs @data} or {}
for k,v in pairs update
new_data[k] = v

import to_json from require "lapis.util"
@update data: db.raw db.escape_literal to_json new_data

0 comments on commit 7273d44

Please sign in to comment.