From a57ad1b134763b55f9dcc0a63e6995a66bcc2a7d Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 16 Mar 2011 16:02:46 +0000 Subject: timestamp as text 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 -- cgit v0.10.2