summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2011-03-16 16:02:46 (GMT)
committerChristian Pointner <equinox@helsinki.at>2011-03-16 16:02:46 (GMT)
commita57ad1b134763b55f9dcc0a63e6995a66bcc2a7d (patch)
tree35bf6ce2abdb4d159e5f63e5e35f0bced82d68d1
parent0ae418d89c3725ca72510467e8cfa55adefc8c6b (diff)
timestamp as text
-rwxr-xr-xnopsyncd/tcpserver.lua10
-rw-r--r--nopsyncd/tempstorage.lua5
2 files changed, 7 insertions, 8 deletions
diff --git a/nopsyncd/tcpserver.lua b/nopsyncd/tcpserver.lua
index d298eed..3f7c70a 100755
--- a/nopsyncd/tcpserver.lua
+++ b/nopsyncd/tcpserver.lua
@@ -86,11 +86,11 @@ end
function main_loop()
local pipefd = pipe.getreadfd()
- -- local ret, err = tempstorage:init()
- -- if ret == nil then
- -- io.stderr:write("creation of tempstorage failed: " .. err .. "\n")
- -- os.exit(1)
- -- end
+ local ret, err = tempstorage:init()
+ if ret == nil then
+ io.stderr:write("creation of tempstorage failed: " .. err .. "\n")
+ os.exit(1)
+ end
server = init_server()
diff --git a/nopsyncd/tempstorage.lua b/nopsyncd/tempstorage.lua
index d40ee42..4ae437a 100644
--- a/nopsyncd/tempstorage.lua
+++ b/nopsyncd/tempstorage.lua
@@ -41,7 +41,7 @@ function tempstorage:init()
return nil, err
end
- local rows, err = self.con:execute("CREATE TABLE IF NOT EXISTS now (timestamp INT PRIMARY KEY ASC NOT NULL, cart INT NOT NULL, len INT, showtitle VARCHAR(255), title VARCHAR(255), artist VARCHAR(255), album VARCHAR(255), ismusic BOOLEAN)")
+ local rows, err = self.con:execute("CREATE TABLE IF NOT EXISTS now (timestamp VARCHAR(16) PRIMARY KEY ASC NOT NULL, cart INT NOT NULL, len INT, showtitle VARCHAR(255), title VARCHAR(255), artist VARCHAR(255), album VARCHAR(255), ismusic BOOLEAN)")
if rows == nil then
return nil, err
end
@@ -61,7 +61,6 @@ function tempstorage:getLastCart()
end
function tempstorage:insertMusic(timestamp, cart, len, title, artist, album)
- timestamp = tonumber(timestamp)
cart = tonumber(cart)
len = tonumber(len)
if cart < 400000 or cart > 450000 then
@@ -70,7 +69,7 @@ function tempstorage:insertMusic(timestamp, cart, len, title, artist, album)
poolnum = math.floor(cart/1000) - 399
end
-- usage of undocumented escape function...
- local cur, err = self.con:execute("INSERT into now VALUES(" .. timestamp .. ", " .. cart .. ", " .. len .. ", 'Musikpool " .. poolnum .. "', '" .. self.con:escape(title) .. "', '" .. self.con:escape(artist) .."', '" .. self.con:escape(album) .. "', 1)")
+ local cur, err = self.con:execute("INSERT into now VALUES(" .. self.con:escape(timestamp) .. ", " .. cart .. ", " .. len .. ", 'Musikpool " .. poolnum .. "', '" .. self.con:escape(title) .. "', '" .. self.con:escape(artist) .."', '" .. self.con:escape(album) .. "', 1)")
if cur == nil then
return nil, err
end