Permalink
Browse files

verden muss phremoffer

  • Loading branch information...
comotion committed Nov 21, 2012
1 parent b0fc629 commit 0b4020f4f00b1b5fb59dfec74a733ad4698742d4
Showing with 13 additions and 2 deletions.
  1. +6 −1 web/hangover.lua
  2. +7 −1 web/lib/tracks.lua
View
@@ -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
@@ -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
View
@@ -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

0 comments on commit 0b4020f

Please sign in to comment.