svnno****@sourc*****
svnno****@sourc*****
2008年 4月 22日 (火) 22:18:07 JST
Revision: 427 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=bbs2ch&view=rev&rev=427 Author: flyson Date: 2008-04-22 22:18:06 +0900 (Tue, 22 Apr 2008) Log Message: ----------- データベースのテーブルを変更 ログフォルダを logs-050 に変更 Modified Paths: -------------- trunk/bbs2chreader/chrome/content/bbs2chreader/components/b2rGlobalIO.js trunk/bbs2chreader/chrome/content/bbs2chreader/components/b2rStorageBoard.js trunk/bbs2chreader/chrome/content/bbs2chreader/components/b2rStorageThread.js trunk/bbs2chreader/components/b2rStorageService.js trunk/bbs2chreader/components/nsBbs2chService.js -------------- next part -------------- Modified: trunk/bbs2chreader/chrome/content/bbs2chreader/components/b2rGlobalIO.js =================================================================== --- trunk/bbs2chreader/chrome/content/bbs2chreader/components/b2rGlobalIO.js 2008-04-07 14:26:32 UTC (rev 426) +++ trunk/bbs2chreader/chrome/content/bbs2chreader/components/b2rGlobalIO.js 2008-04-22 13:18:06 UTC (rev 427) @@ -92,7 +92,7 @@ getLogFileAtBoardID: function(aBoardID){ - const LOGS_DIR_NAME = "logs-050pre2"; + const LOGS_DIR_NAME = "logs-050"; var logFile = this.getDataDir(); logFile.appendRelativePath(LOGS_DIR_NAME); Modified: trunk/bbs2chreader/chrome/content/bbs2chreader/components/b2rStorageBoard.js =================================================================== --- trunk/bbs2chreader/chrome/content/bbs2chreader/components/b2rStorageBoard.js 2008-04-07 14:26:32 UTC (rev 426) +++ trunk/bbs2chreader/chrome/content/bbs2chreader/components/b2rStorageBoard.js 2008-04-22 13:18:06 UTC (rev 427) @@ -49,6 +49,7 @@ if(!database.tableExists("board_subject")){ let sql = <> CREATE TABLE board_subject( + thread_id TEXT NOT NULL UNIQUE, board_id TEXT NOT NULL, dat_id TEXT NOT NULL, title TEXT, @@ -58,13 +59,12 @@ ); </>.toString().replace(/\t/g, ""); database.executeSimpleSQL(sql); - database.executeSimpleSQL("CREATE INDEX IF NOT EXISTS board_subject_board_id_index ON board_subject(board_id);"); } if(!database.tableExists("board_data")){ let sql = <> CREATE TABLE board_data( - board_id TEXT NOT NULL, + board_id TEXT NOT NULL UNIQUE, url TEXT NOT NULL, title TEXT, title_n TEXT, @@ -76,7 +76,6 @@ ); </>.toString().replace(/\t/g, ""); database.executeSimpleSQL(sql); - database.executeSimpleSQL("CREATE INDEX IF NOT EXISTS board_data_board_id_index ON board_data(board_id);"); } }catch(ex){ Components.utils.reportError(ex); @@ -86,7 +85,7 @@ this._statements = new Array(); this._statements["boardSubjectUpdate_insert"] = database.createStatement( - "INSERT INTO board_subject(board_id, dat_id, title, title_n, line_count, ordinal) VALUES(?1,?2,?3,?4,?5,?6);"); + "INSERT INTO board_subject(thread_id, board_id, dat_id, title, title_n, line_count, ordinal) VALUES(?1,?2,?3,?4,?5,?6,?7);"); this._statements["_setBoardData_select"] = database.createStatement( "SELECT _rowid_ FROM board_data WHERE board_id=?1;"); @@ -142,16 +141,18 @@ do { c = fileStream.readLine(line); if(!regLine.test(line.value)) continue; - let datID = RegExp.$1; - let title = gStorageService._html2Text(RegExp.$2); - let count = Number(RegExp.$3); + var datID = RegExp.$1; + var threadID = boardID + datID; + var title = gStorageService._html2Text(RegExp.$2); + var count = Number(RegExp.$3); - statement.bindStringParameter(0, boardID); - statement.bindStringParameter(1, datID); - statement.bindStringParameter(2, title); - statement.bindStringParameter(3, gStorageService._getNormarizedString(title)); - statement.bindInt32Parameter(4, count); - statement.bindInt32Parameter(5, ordinal); + statement.bindStringParameter(0, threadID); + statement.bindStringParameter(1, boardID); + statement.bindStringParameter(2, datID); + statement.bindStringParameter(3, title); + statement.bindStringParameter(4, gStorageService._getNormarizedString(title)); + statement.bindInt32Parameter(5, count); + statement.bindInt32Parameter(6, ordinal); statement.execute(); ordinal++; }while(c); Modified: trunk/bbs2chreader/chrome/content/bbs2chreader/components/b2rStorageThread.js =================================================================== --- trunk/bbs2chreader/chrome/content/bbs2chreader/components/b2rStorageThread.js 2008-04-07 14:26:32 UTC (rev 426) +++ trunk/bbs2chreader/chrome/content/bbs2chreader/components/b2rStorageThread.js 2008-04-22 13:18:06 UTC (rev 427) @@ -48,6 +48,7 @@ if(!database.tableExists("thread_data")){ let sql = <> CREATE TABLE thread_data( + thread_id TEXT NOT NULL UNIQUE, board_id TEXT NOT NULL, url TEXT NOT NULL, dat_id TEXT NOT NULL, @@ -64,8 +65,6 @@ ); </>.toString().replace(/\t/g, ""); database.executeSimpleSQL(sql); - database.executeSimpleSQL("CREATE INDEX IF NOT EXISTS thread_data_board_id_index ON thread_data(board_id);"); - database.executeSimpleSQL("CREATE INDEX IF NOT EXISTS thread_data_dat_id_index ON thread_data(dat_id);"); } }catch(ex){ Components.utils.reportError(ex); @@ -75,15 +74,15 @@ this._statements = new Array(); this._statements["setThreadData_select"] = database.createStatement( - "SELECT _rowid_ FROM thread_data WHERE board_id=?1 AND dat_id=?2;"); + "SELECT _rowid_ FROM thread_data WHERE thread_id=?1;"); this._statements["setThreadData_update"] = database.createStatement( "UPDATE thread_data SET url=?1, line_count=?2, http_last_modified=?3, maru_getted=?4 WHERE _rowid_=?5;"); this._statements["setThreadData_insert"] = database.createStatement( - "INSERT INTO thread_data(board_id, url, dat_id, title, title_n, line_count, http_last_modified, maru_getted) VALUES(?1,?2,?3,?4,?5,?6,?7,?8);"); + "INSERT INTO thread_data(thread_id, board_id, url, dat_id, title, title_n, line_count, http_last_modified, maru_getted) VALUES(?1,?2,?3,?4,?5,?6,?7,?8,?9);"); this._statements["getThreadData_select"] = database.createStatement( - "SELECT board_id, url, dat_id, title, title_n, line_count, read_position, http_last_modified, " - + "maru_getted, stored, post_name, post_mail, rate FROM thread_data WHERE board_id=?1 AND dat_id=?2"); + "SELECT thread_id, board_id, url, dat_id, title, title_n, line_count, read_position, http_last_modified, " + + "maru_getted, stored, post_name, post_mail, rate FROM thread_data WHERE thread_id=?1;"); this._statements["deleteThreadData_delete"] = database.createStatement( "DELETE FROM thread_data WHERE board_id=?1 AND dat_id=?2"); @@ -93,37 +92,38 @@ setThreadData: function(aThreadURL, aBoardURL, aDatID, aTitle, aLineCount, aLastModified, aMaruGetted){ var b2rService = XPC.getService("@bbs2ch.sourceforge.jp/b2r-global-service;1", "b2rIGlobalService"); var boardID = b2rService.threadUtils.getBoardID(aBoardURL); + var threadID = boardID + aDatID; var database = gStorageService.database; database.beginTransaction(); try{ var statement; statement = this._statements["setThreadData_select"]; - statement.bindStringParameter(0, boardID); - statement.bindStringParameter(1, aDatID); - var threadID = 0; + statement.bindStringParameter(0, threadID); + var threadRowID = 0; if(statement.executeStep()){ - threadID = statement.getInt64(0); + threadRowID = statement.getInt64(0); } statement.reset(); - if(threadID){ + if(threadRowID){ statement = this._statements["setThreadData_update"]; statement.bindStringParameter(0, aThreadURL.spec); statement.bindInt32Parameter(1, aLineCount); statement.bindStringParameter(2, aLastModified); statement.bindInt32Parameter(3, aMaruGetted ? 1 : 0); - statement.bindInt64Parameter(4, threadID); + statement.bindInt64Parameter(4, threadRowID); statement.execute(); }else{ statement = this._statements["setThreadData_insert"]; - statement.bindStringParameter(0, boardID); - statement.bindStringParameter(1, aThreadURL.spec); - statement.bindStringParameter(2, aDatID); - statement.bindStringParameter(3, aTitle); - statement.bindStringParameter(4, gStorageService._getNormarizedString(aTitle)); - statement.bindInt32Parameter(5, aLineCount); - statement.bindStringParameter(6, aLastModified); - statement.bindInt32Parameter(7, aMaruGetted ? 1 : 0); + statement.bindStringParameter(0, threadID); + statement.bindStringParameter(1, boardID); + statement.bindStringParameter(2, aThreadURL.spec); + statement.bindStringParameter(3, aDatID); + statement.bindStringParameter(4, aTitle); + statement.bindStringParameter(5, gStorageService._getNormarizedString(aTitle)); + statement.bindInt32Parameter(6, aLineCount); + statement.bindStringParameter(7, aLastModified); + statement.bindInt32Parameter(8, aMaruGetted ? 1 : 0); statement.execute(); } }catch(ex){ @@ -137,28 +137,29 @@ getThreadData: function(aBoardURL, aDatID){ var b2rService = XPC.getService("@bbs2ch.sourceforge.jp/b2r-global-service;1", "b2rIGlobalService"); var boardID = b2rService.threadUtils.getBoardID(aBoardURL); + var threadID = boardID + aDatID; var statement = this._statements["getThreadData_select"]; - statement.bindStringParameter(0, boardID); - statement.bindStringParameter(1, aDatID); + statement.bindStringParameter(0, threadID); var result = null; gStorageService.database.beginTransaction(); try{ if(statement.executeStep()){ result = new b2rThreadData( - statement.getString(0), // boardID - statement.getString(1), // url - statement.getString(2), // datID - statement.getString(3), // title - statement.getString(4), // titleN - statement.getInt32(5), // lineCount - statement.getInt32(6), // readPosition - statement.getString(7), // httpLastModified - statement.getInt32(8), // maruGetted - statement.getInt32(9), // stored - statement.getString(10), // postName - statement.getString(11), // postMail - statement.getInt32(12) // rate + // statement.getString(0), // thread_id + statement.getString(1), // boardID + statement.getString(2), // url + statement.getString(3), // datID + statement.getString(4), // title + statement.getString(5), // titleN + statement.getInt32(6), // lineCount + statement.getInt32(7), // readPosition + statement.getString(8), // httpLastModified + statement.getInt32(9), // maruGetted + statement.getInt32(10), // stored + statement.getString(11), // postName + statement.getString(12), // postMail + statement.getInt32(13) // rate ); } }catch(ex){ Modified: trunk/bbs2chreader/components/b2rStorageService.js =================================================================== --- trunk/bbs2chreader/components/b2rStorageService.js 2008-04-07 14:26:32 UTC (rev 426) +++ trunk/bbs2chreader/components/b2rStorageService.js 2008-04-22 13:18:06 UTC (rev 427) @@ -92,7 +92,7 @@ _startup: function(){ var b2rService = XPC.getService("@bbs2ch.sourceforge.jp/b2r-global-service;1", "b2rIGlobalService"); var dbFile = b2rService.io.getDataDir(); - dbFile.appendRelativePath("logs-050pre2"); + dbFile.appendRelativePath("logs-050"); dbFile.appendRelativePath("storage.sqlite"); if(!dbFile.exists()){ dbFile.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, 0666); Modified: trunk/bbs2chreader/components/nsBbs2chService.js =================================================================== --- trunk/bbs2chreader/components/nsBbs2chService.js 2008-04-07 14:26:32 UTC (rev 426) +++ trunk/bbs2chreader/components/nsBbs2chService.js 2008-04-22 13:18:06 UTC (rev 427) @@ -340,7 +340,7 @@ }, getLogFileAtURL: function(aURLSpec){ - const LOGS_DIR_NAME = "logs-050pre2"; + const LOGS_DIR_NAME = "logs-050"; var fromURL = this._ioService.newURI(aURLSpec, null, null).QueryInterface(Ci.nsIURL);