Skip to content

Commit

Permalink
verden muss phremoffer
Browse files Browse the repository at this point in the history
  • Loading branch information
comotion committed Nov 21, 2012
1 parent b0fc629 commit 0b4020f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion web/hangover.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ function post_db(web,...)
if not tags then
return failure
end
-- make a default title out of filename
if not tags.title then
tags.title = tags.filename:gsub(".(%w+)$","")
end

-- add to database, tags and all
id = tracks:add(tags)
-- add to database, tags and all
Expand Down Expand Up @@ -147,7 +152,7 @@ function put_db(web,...)
web.status = "501 someone fucked up"
return json.encode{{result=nil, error="nothing to put"}}
end
if not tracks:update(id, input) then
if not tracks:put(id, input) then
web.status = "501 fubar"
return json.encode{{result=nil, error="failed to put"}}
end
Expand Down
8 changes: 7 additions & 1 deletion web/lib/tracks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,13 @@ function tracks:get(pkey)
end

function tracks:update(pkey, cols)
return tracks:put(pkey, cols)
p = tracks:get(pkey)
-- merge teh data
for k,v in pairs(cols) do
p[k] = v
end
cols.updated = os.time()
return tracks:put(pkey, p)
end

-- return result with only fields
Expand Down

0 comments on commit 0b4020f

Please sign in to comment.