Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: experimental/webtry/webtry.go

Issue 669643004: webtry: Improve error handling/message when creating sqlite tables. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package main 1 package main
2 2
3 import ( 3 import (
4 "bytes" 4 "bytes"
5 "crypto/md5" 5 "crypto/md5"
6 "database/sql" 6 "database/sql"
7 "encoding/base64" 7 "encoding/base64"
8 "encoding/binary" 8 "encoding/binary"
9 "encoding/json" 9 "encoding/json"
10 "flag" 10 "flag"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 sql := `CREATE TABLE IF NOT EXISTS source_images ( 228 sql := `CREATE TABLE IF NOT EXISTS source_images (
229 id INTEGER PRIMARY KEY NOT NULL, 229 id INTEGER PRIMARY KEY NOT NULL,
230 image MEDIUMBLOB DEFAULT '' NOT NULL, -- forma tted as a PNG. 230 image MEDIUMBLOB DEFAULT '' NOT NULL, -- forma tted as a PNG.
231 width INTEGER DEFAULT 0 NOT NULL, 231 width INTEGER DEFAULT 0 NOT NULL,
232 height INTEGER DEFAULT 0 NOT NULL, 232 height INTEGER DEFAULT 0 NOT NULL,
233 create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, 233 create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
234 hidden INTEGER DEFAULT 0 NOT NULL 234 hidden INTEGER DEFAULT 0 NOT NULL
235 )` 235 )`
236 _, err = db.Exec(sql) 236 _, err = db.Exec(sql)
237 if err != nil { 237 if err != nil {
238 » » » glog.Infof("status creating sqlite table for sources: %q \n", err) 238 » » » glog.Errorf("Creating source_images table failed: %s", e rr)
239 } 239 }
240 240
241 sql = `CREATE TABLE IF NOT EXISTS webtry ( 241 sql = `CREATE TABLE IF NOT EXISTS webtry (
242 code TEXT DEFAULT '' NOT NULL, 242 code TEXT DEFAULT '' NOT NULL,
243 create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, 243 create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
244 hash CHAR(64) DEFAULT '' NOT NULL, 244 hash CHAR(64) DEFAULT '' NOT NULL,
245 width INTEGER DEFAULT 256 NOT NULL, 245 width INTEGER DEFAULT 256 NOT NULL,
246 height INTEGER DEFAULT 256 NOT NULL, 246 height INTEGER DEFAULT 256 NOT NULL,
247 gpu BOOL DEFAULT 0 NOT NULL, 247 gpu BOOL DEFAULT 0 NOT NULL,
248 source_image_id INTEGER DEFAULT 0 NOT NULL, 248 source_image_id INTEGER DEFAULT 0 NOT NULL,
249 249
250 PRIMARY KEY(hash) 250 PRIMARY KEY(hash)
251 )` 251 )`
252 _, err = db.Exec(sql) 252 _, err = db.Exec(sql)
253 if err != nil { 253 if err != nil {
254 » » » glog.Infof("status creating sqlite table for webtry: %q\ n", err) 254 » » » glog.Errorf("Creating webtry table failed: %s", err)
255 } 255 }
256 256
257 sql = `CREATE TABLE IF NOT EXISTS workspace ( 257 sql = `CREATE TABLE IF NOT EXISTS workspace (
258 name CHAR(64) DEFAULT '' NOT NULL, 258 name CHAR(64) DEFAULT '' NOT NULL,
259 create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, 259 create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
260 PRIMARY KEY(name) 260 PRIMARY KEY(name)
261 )` 261 )`
262 _, err = db.Exec(sql) 262 _, err = db.Exec(sql)
263 if err != nil { 263 if err != nil {
264 » » » glog.Infof("status creating sqlite table for workspace: %q\n", err) 264 » » » glog.Errorf("Creating workspace table failed: %s", err)
265 } 265 }
266 266
267 sql = `CREATE TABLE IF NOT EXISTS workspacetry ( 267 sql = `CREATE TABLE IF NOT EXISTS workspacetry (
268 name CHAR(64) DEFAULT '' NOT NULL, 268 name CHAR(64) DEFAULT '' NOT NULL,
269 create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, 269 create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
270 hash CHAR(64) DEFAULT '' NOT NULL, 270 hash CHAR(64) DEFAULT '' NOT NULL,
271 width INTEGER DEFAULT 256 NOT NULL, 271 width INTEGER DEFAULT 256 NOT NULL,
272 height INTEGER DEFAULT 256 NOT NULL, 272 height INTEGER DEFAULT 256 NOT NULL,
273 gpu BOOL DEFAULT 0 NOT NULL, 273 gpu BOOL DEFAULT 0 NOT NULL,
274 hidden INTEGER DEFAULT 0 NOT NULL, 274 hidden INTEGER DEFAULT 0 NOT NULL,
275 source_image_id INTEGER DEFAULT 0 NOT NULL, 275 source_image_id INTEGER DEFAULT 0 NOT NULL,
276 276
277 FOREIGN KEY (name) REFERENCES workspace(name) 277 FOREIGN KEY (name) REFERENCES workspace(name)
278 )` 278 )`
279 _, err = db.Exec(sql) 279 _, err = db.Exec(sql)
280 if err != nil { 280 if err != nil {
281 » » » glog.Infof("status creating sqlite table for workspace t ry: %q\n", err) 281 » » » glog.Errorf("Creating workspacetry table failed: %s", er r)
282 } 282 }
283 } 283 }
284 284
285 // Ping the database to keep the connection fresh. 285 // Ping the database to keep the connection fresh.
286 go func() { 286 go func() {
287 c := time.Tick(1 * time.Minute) 287 c := time.Tick(1 * time.Minute)
288 for _ = range c { 288 for _ = range c {
289 if err := db.Ping(); err != nil { 289 if err := db.Ping(); err != nil {
290 glog.Errorf("Database failed to respond: %q\n", err) 290 glog.Errorf("Database failed to respond: %q\n", err)
291 } 291 }
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 http.HandleFunc("/sources/", autogzip.HandleFunc(sourcesHandler)) 961 http.HandleFunc("/sources/", autogzip.HandleFunc(sourcesHandler))
962 962
963 // Resources are served directly 963 // Resources are served directly
964 // TODO add support for caching/etags/gzip 964 // TODO add support for caching/etags/gzip
965 http.Handle("/res/", autogzip.Handle(http.FileServer(http.Dir("./")))) 965 http.Handle("/res/", autogzip.Handle(http.FileServer(http.Dir("./"))))
966 966
967 // TODO Break out /c/ as it's own handler. 967 // TODO Break out /c/ as it's own handler.
968 http.HandleFunc("/", autogzip.HandleFunc(mainHandler)) 968 http.HandleFunc("/", autogzip.HandleFunc(mainHandler))
969 glog.Fatal(http.ListenAndServe(*port, nil)) 969 glog.Fatal(http.ListenAndServe(*port, nil))
970 } 970 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698