|
|
@@ -46,6 +46,8 @@ SELECT_ORIGIN_PATH_STMT = 'SELECT origin_path FROM photoinfo WHERE lensman = ? a
|
46
|
46
|
|
47
|
47
|
conn = sqlite3.connect('minipai2.db')
|
48
|
48
|
cur = conn.cursor()
|
|
49
|
+# Synchronous Off
|
|
50
|
+cur.execute('PRAGMA synchronous = OFF')
|
49
|
51
|
# Execute SQL
|
50
|
52
|
cur.execute(CREATE_TABLE_STMT)
|
51
|
53
|
cur.execute(CREATE_INDEX1)
|
|
|
@@ -108,8 +110,8 @@ def get_last_timestamp(lensman, session):
|
108
|
110
|
return int(result[0][0] or 0)
|
109
|
111
|
|
110
|
112
|
|
111
|
|
-def insert_session_file(lensman, session, id, name, thumb, origin):
|
112
|
|
- cur.execute(INSERT_RECORD_STMT, (lensman, session, id, name, thumb, origin))
|
|
113
|
+def insert_session_file(files_):
|
|
114
|
+ cur.executemany(INSERT_RECORD_STMT, files_)
|
113
|
115
|
conn.commit()
|
114
|
116
|
|
115
|
117
|
|
|
|
@@ -121,7 +123,9 @@ def delete_session_file(lensman, session, name):
|
121
|
123
|
def get_new_files(lensman, session, maxid, maxt):
|
122
|
124
|
_, thumb = get_session_dir(lensman, session)
|
123
|
125
|
files = glob.iglob('{}/*'.format(thumb))
|
124
|
|
- news = []
|
|
126
|
+ # Init Vars
|
|
127
|
+ news, files_ = [], []
|
|
128
|
+ # Foreach Glob Files
|
125
|
129
|
for file_ in files:
|
126
|
130
|
logit('/fetch_thumbnail', file_, key='globfile')
|
127
|
131
|
if not file_.endswith('.tmp'): # Whether 'xxx.tmp' or not
|
|
|
@@ -143,7 +147,10 @@ def get_new_files(lensman, session, maxid, maxt):
|
143
|
147
|
})
|
144
|
148
|
# Insert When Photo_id Large Than Maxt
|
145
|
149
|
if int(photo_id) > maxt:
|
146
|
|
- insert_session_file(lensman, session, photo_id, photo_name, thumb_path, origin_path)
|
|
150
|
+ files_.append((lensman, session, photo_id, photo_name, thumb_path, origin_path))
|
|
151
|
+ # If Having Files To Insert Into SQLite
|
|
152
|
+ if files_:
|
|
153
|
+ insert_session_file(files_)
|
147
|
154
|
return news
|
148
|
155
|
|
149
|
156
|
|